The Weird Algorithm
Print the whole Collatz trajectory of N (even → halve, odd → 3N+1) until it reaches 1, inclusive.
Input: one integer N.
Output: the full sequence on one line.
Constraints:
- 1 ≤ N ≤ 106
Sample Tests
Input 1
3
Output 1
3 10 5 16 8 4 2 1
Input 2
1
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.