#P3394. Weird Algorithm

Weird Algorithm

当前没有测试数据。

Description

Consider an algorithm that takes as input a positive integer . If  is even, the algorithm divides it by two, and if  is odd, the algorithm multiplies it by three and adds one. The algorithm repeats this, until n is one. For example, the sequence for n=3 is as follows: Your task is to simulate the execution of the algorithm for a given value of n.


Input Format

The only input line contains an integer n.

Output Format

Print a line that contains all values of  during the algorithm.
3
3 10 5 16 8 4 2 1

Hint

  • 1n106

Source

CSES