The Collatz Code

来源:互联网 发布:关于广州plc编程员招聘 编辑:程序博客网 时间:2024/06/05 11:10

Description

The cows are having a merry little game with numbers.  One of the cowspicks a positive integer N that is smaller than 32000.  The cows thenplace bets on whether the length of the 'Collatz Sequence' will exceeda number like 100.The Collatz Sequence is calculated thusly.  Start with an integer, C.* if C is 1, the sequence has endedOtherwise,* if C is even, then divide it by two to yield a new C* if C is odd, then replace it by 3*C+1        Continue the rules until the sequence ends.Consider the Collatz Sequence that starts with the integer 10:10, 5, 16, 8, 4, 2, 1It has length 7.Help one of the cows cheat.  Given N, calculate the length of theCollatz Sequence.

Input

A single line with a single integer: N

Output

A single line with a single integer that is the length of the CollatzSequence starting with N

Sample Input

10

Sample Output

7
代码



0 0