Problem D
Collatz Conjecture
Let
The Collatz conjecture states that this sequence
will always reach
For example, if
Write a program that reads a positive integer from the user
and, using a while loop, outputs each element of the above
sequence until it reaches
Input
Input consists of one line with one integer
Output
Output consists of one or more lines, where the
Sample Input 1 | Sample Output 1 |
---|---|
2 |
2 1 |
Sample Input 2 | Sample Output 2 |
---|---|
3 |
3 10 5 16 8 4 2 1 |
Sample Input 3 | Sample Output 3 |
---|---|
19 |
19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 |
Sample Input 4 | Sample Output 4 |
---|---|
25 |
25 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 |