Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 16M

Problem type

Pick a positive integer n. If it is odd, multiply it by three and then add one. Otherwise (if it is even), divide it by two. The positive integer obtained is the new n, and this procedure is repeated.

It is believed that n will eventually become 1 (this is called the Collatz conjecture.) Computers have checked that any value of n less than 10^{20} does, indeed, eventually become 1 if this procedure is applied enough times.

You will be given the value of n. Determine how many times this procedure must be applied before n becomes 1.

Input Specification

The initial value of n.

Output Specification

The number of operations we have to perform on n before it becomes 1.

Constraints

Any value of n, initial or intermediate, will be less than 2^{31}.

Sample Input

7

Sample Output

16

Explanation

n will go through these steps:

\displaystyle 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1


Comments


  • 5
    OneYearOld  commented on Oct. 28, 2020, 1:23 p.m. edited

    The test data is very weak. 0 < n < 35655.


    • 1
      QooModa  commented on May 10, 2022, 10:15 p.m.

      Genuine question.

      How do you check the test data?

      It would help me solve other problems, I think...

      Thanks!


      • 0
        Smug_Void  commented on March 29, 2023, 3:20 p.m.

        copy the input data and then just print it out


      • 1
        FlowerPollinator  commented on Sept. 26, 2022, 11:06 p.m.

        You don't, unless the problem originated from somewhere else