#B2077. Collatz Sequence Process

    ID: 11159 Type: Default 1000ms 256MiB

Collatz Sequence Process

Collatz Sequence Process

The Collatz Conjecture (also known as the 3n + 1 problem) states that for any positive integer, if the number is odd, multiply it by \(3\) and add \(1\); if it is even, divide it by \(2\). Repeating this process will eventually yield the number \(1\). For example, if the initial integer is \(5\), the sequence of operations is: \(5 \to 16 \to 8 \to 4 \to 2 \to 1\).

Your task is to write a program that reads a positive integer and prints the sequence of numbers obtained by repeatedly applying the above rule until \(1\) is reached. Note that the initial number is not part of the output; only the subsequent numbers are output.

inputFormat

The input consists of a single positive integer \(n\) (\(1 \leq n \leq 10^9\)).

outputFormat

Output the sequence of numbers obtained by applying the Collatz process. The numbers should be separated by a space. If the input is already \(1\), the program should output nothing.

sample

5
16 8 4 2 1