#ZJ001. [ZJ-001] 冰雹猜想/角谷猜想
[ZJ-001] 冰雹猜想/角谷猜想
Background
The Collatz Conjecture states that:
For any positive integer :
-
If it's odd, multiply it by and add , i.e.: ;
-
If it's even, divide it by , i.e.: .
By repeating these operations, the number will eventually reach and fall into the loop.
Description
Now, write a program to calculate how many operations are needed for a positive integer to transform into .
Input
A single line containing the positive integer to be processed.
Output
A non-negative integer , representing the number of operations required.
7
16
8
3
Hint
【Data Scale and Convention】
For of the data, .
相关
在下列比赛中: