#P6206. Collatz Sequence Game
Collatz Sequence Game
Collatz Sequence Game
Bessie the cow is playing a number game and needs your help to predict the final score. The game starts with a positive integer \(N\) and an initial score of \(0\). The number \(N\) is then transformed repeatedly according to the following rules:
- If \(N\) is odd, assign \(N \leftarrow 3 \times N + 1\).
- If \(N\) is even, assign \(N \leftarrow \frac{N}{2}\).
Each transformation increases the score by \(1\). The game ends when \(N = 1\), and the final score is the total number of operations performed.
inputFormat
The input consists of a single positive integer \(N\) (\(1 \leq N \leq 10^{18}\)).
outputFormat
Output the final score, which is the number of transformations required to reach \(N = 1\).
sample
1
0