# The 3n + 1 problem I

1000ms    65536K
477    209
Beginner

Description

Problems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will be analyzing a property of an algorithm whose classification is not known for all possible inputs. Consider the following algorithm:


1. 		 input n

2. 		 print n

3. 		 if n = 1 then STOP

4. 		 		 if n is odd then   n <-- 3n+1

5. 		 		 else   n <-- n/2

6. 		 GOTO 2



Given the input 22, the following sequence of numbers will be printed 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1

Input

Input contain multiple lines of integer number N. (0 < N ≤ 100000)

Last line is 0, indicate the end of the test case.

Output

For each test case, output the all numbers of the N to 1 with this algorithm in one line. Format as example output.

Sample Input

10
22
0

Sample Output

the following sequence of numbers 10 will be printed :10 5 16 8 4 2 1
the following sequence of numbers 22 will be printed :22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1

Source

Editor

keefo on 2014-10-24 16:14:47