9280 - The 3n+1 Problem   

Description

  Consider the following algorithm:

  1. Input n
  2. Set Count to be 0
  3. If n is equal to 1, then STOP
    Else Set 
  4. Count = Count +1
  5. GOTO Step 3.

Given one integer n. Please output the count after processing the algorithm.

 

For example:

If n = 22, then according to the algorithm. You will get 22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1. Thus the count for 22 is 15.

 

Input

The input contains several test cases and will end with EOF. In each test case, there is only one line contains an integer n.

For 9280: 1<=n<=1500

For 9281: 1<=n<=9000

For 9282: 1<=n<=100000

For 9283: 1<=n<=1000000

[Hint]

For 9280, the value during operation will not exceed 10^6. Time: 3s.

For 9281, the value during operation will not exceed 10^7. Time: 3s.

For 9282, the value during operation will not exceed 2^31. Time: 3s.

For 9283, the value during operation will not exceed 2^63. Time: 1s.

For 9283, and you may need to store the count of n that has already been calculated.

Please don't use cin/cout, or you will get TLE.

Output

 For each test case, output the count of n.

Sample Input  Download

Sample Output  Download

Tags




Discuss