Print the Collatz sequence until it reaches 1.
Read a positive integer N. Print each step of the Collatz sequence (one per line) until you reach 1 (include the 1).
Rules: if even -> n//2, if odd -> 3*n+1.
Test input: 10
Expected output:
10
5
16
8
4
2
1
Sign in to save your code and track progress across devices.