#P214. 练35.4 奶牛的数字游戏
练35.4 奶牛的数字游戏
Description
The cows are playing another boring number game. Bessie, who is losing miserably, wants you to write a program to help her predict the outcome at the start of the game. At the beginning of the game, each cow gets a number N. Initially, all cows' scores are 0. If N is odd, the cow multiplies it by 3 and adds 1. If N is even, the number is divided by 2. Each time the number changes, the cow gets 1 point. When N equals 1, the game ends, and the score at that point is the cow's final score for the game.
Here's a complete game process when N starts at 5:
5→16→8→4→2→1.
Input Format
Input an integer between 1 and 10^6.
Output Format
Output an integer N, representing the cow's final score in this game. It is guaranteed that the numbers will not exceed the int range after each transformation.
Sample
11220