221. Collatz Steps
Start with n. If it is even, halve it. If it is odd, replace it with
3n + 1. Repeat until you reach 1, and print how many steps that took.
6 -> 3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 is 8 steps
This one is worth knowing about beyond the exercise. Nobody has proved that every starting value reaches 1, and it has been an open problem since 1937. It has been checked for every number up to about 2^68, so your input is safe.
Watch the intermediate values. Starting from a number near the limit, 3n + 1
can exceed a 32-bit integer even though the input does not.
Constraints - `1 ≤ n ≤ 1000000`
Input
A single line containing one integer n.
Output
Print one integer, the number of steps needed to reach 1.