All problems

Building Polynomial Features

easyPythonLinear Regression

Kestrel Freight's fuel curve is not straight: cost per mile creeps up as runs get longer, and a straight line under-quotes at both ends. The modelling team's answer is to keep the straight-line fitter and give it more columns to work with — as well as the distance itself, the distance squared, the distance cubed, and so on up to a degree they choose. Before any of that can be fitted, the tool needs the small piece that turns one distance into that row of extra columns.

Task: Print the powers of the given distance, from the first power up to the chosen degree.

Input

One line holding two numbers separated by a single space: the distance, which may have a decimal point, and the degree d, a whole number with 1 <= d <= 20.

Output

d lines, one per column, smallest power first: the distance itself, then the distance squared, and so on up to the distance raised to the power d. Each line holds one value rounded to 2 decimal places and nothing else. The zeroth power, which is always 1, is not one of the columns and must not be printed.

Example:

Input:
2 3

Output:
2.00
4.00
8.00

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…