Collatz
Details
The Collatz conjecture states that, for any positive integer n, it will eventually reach 1 by repeatedly applying the following procedure:
- If n is even, divide it by 2.
- If n is odd, multiply by 3 and then add 1.
The number of steps needed for n to reach 1 is called its stopping time. For example, the stopping time of 10 is six:
10 → 5 → 16 → 8 → 4 → 2 → 1
Print the stopping times of all the numbers from 1 to 1,000 inclusive, each on their own line.
0 bytes, 0 chars
Restore solution
Compiled from
AT&T syntax to x86-64 Linux. Use
syscalls to write output.
ctrl + enter or