Collatz Climb (Math)

Starting from n, halve it if even, otherwise make it 3n + 1. Print how many steps it takes to reach 1.

Input: One integer 1 ≤ n ≤ 10^6.

Output: The step count.

Difficulty: Medium. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • Values can grow past 32 bits along the way.

More Math practice