1739: 【CSP循环】角谷猜想▅

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:9 Solved:7

Description

日本一位中学生发现一个奇妙的定理,请角谷教授证明,而教授无能为力,于是产生了角谷猜想。

猜想的内容:任给一个自然数,若为偶数则除以 lns="http://www.w3.org/1998/Math/MathML">2 ,若为奇数则乘 lns="http://www.w3.org/1998/Math/MathML">3 加 lns="http://www.w3.org/1998/Math/MathML">1 ,得到一个新的自然数后按上面的法则继续演算。若干次后得到的结果必为 lns="http://www.w3.org/1998/Math/MathML">1 。

请编写代码验证该猜想:求经过多少次运算可得到自然数 lns="http://www.w3.org/1998/Math/MathML">1 。

如:输入 lns="http://www.w3.org/1998/Math/MathML">22 ,则计算过程为。

22/2=11
11*3+1=34
34/2=17
17*3+1=52
52/2=26
26/2=13
13*3+1=40
40/2=20
20/2=10
10/2=5
5*3+1=16
16/2=8
8/2=4
4/2=2
2/2=1 

经过 lns="http://www.w3.org/1998/Math/MathML">15 次运算得到自然数 lns="http://www.w3.org/1998/Math/MathML">1 。

Input

一行,一个正整数 lns="http://www.w3.org/1998/Math/MathML">n 。( lns="http://www.w3.org/1998/Math/MathML">1n20000 )

Output

一行,一个整数,表示得到 lns="http://www.w3.org/1998/Math/MathML">1 所用的运算次数。

Sample Input Copy

22

Sample Output Copy

15