142. Collatz Steps
EasySimulation
Starting from n, repeatedly apply n → n/2 if n is even, else 3n + 1. Print how many steps it takes to reach 1.
Input format
A single integer n.
Output format
The number of steps.
Example 1
Input
6
Output
8
Example 2
Input
1
Output
0
Constraints
1 ≤ n ≤ 10⁶
Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.
Loading the MyLoginn IDE…