Problem7478-- [CSES Problem Set] Weird Algorithm

7478: [CSES Problem Set] Weird Algorithm

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

Consider an algorithm that takes as input a positive integer $n$. If $n$ is even, the algorithm divides it by two, and if $n$ 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:
$3→10→5→16→8→4→2→1$
Your task is to simulate the execution of the algorithm for a given value of nn.

Input

The only input line contains an integer $n$.

Output

Print a line that contains all values of $n$ during the algorithm.

Constraints

$1 \leq n \leq 10^6$

Sample 1 Input

3

Sample 1 Output

3 10 5 16 8 4 2 1

Sample 2 Input

1

Sample 2 Output

1

HINT

相同题目:CSES 1068

Source/Category