Back
Close

Collatz conjecture

Statement

 Goal

The Collatz conjecture is a opened mathematics problem: given a number N, the repetition of the following operation will always eventually reach the loop 1 ⇒ 4 ⇒2 ⇒1 ...
* If N is even, N becomes N/2
* If N is odd, N becomes 3*N+1

Can you try it with the given numbers and print the number of steps it took to reach 1?
Input
A starting number N
Output
The number of steps to reach 1
Constraints
0 < N <=10^12
Example
Input
16
Output
4

Game modes
Fastest, Shortest

Test cases
Power of 2 Test
Input
16
Output
4

Power of 2 Validator
Input
8
Output
3

Low value Test
Input
27
Output
111

Low value Validator
Input
31
Output
106

High power of 2 Test
Input
2147483648
Output
31

High power of 2 Validator
Input
1073741824
Output
30

High value Test
Input
75128138247
Output
1228

High value Validator
Input
9780657631
Output
1132

Solution language

Solution

Stub generator input