Doubling Coins (Baby Steps)

A magic coin doubles every day: 1, 2, 4, 8, … Print every amount that is not bigger than n, one on each line.

Input: One integer n (1 to 1000000).

Output: The amounts 1, 2, 4, … up to n, one per line.

Difficulty: Easy. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • Start with 1 and use a while loop that keeps going while the amount is at most n.

More Baby Steps practice