Number Reduction

면접 대비

시간 제한1초메모리 제한2048 MB

요약
정수에서 시작해 짝수면 절반으로, 홀수면 3n+1로 바꾸는 과정을 1이 될 때까지 반복하고 걸린 횟수를 센다.
난이도

쉬움10점 중 2점

유형
시뮬레이션, 구현, 수학
정답자
아직 제출이 없습니다

문제

Christopher loves the number one. In fact, he loves it so much that if he ever has more than one of something, he makes sure to get rid of all but one of his items. Christopher has one pencil, one notebook, one sweatshirt, and so on.

However, Christopher has gotten bored of just giving away all but one of his possessions of each type. Instead, he has come up with a new strategy, which depends on the number of items he has already. If he has an even number of something, then he will give away half of what he has. If he has an odd number of things, then he will buy some more of that item: he will add twice as many items as he currently has, plus one more item, to his collection. He does this until he has just one item left.

For example, if he has 55 phone chargers, then to get rid of them he would first buy 1111 more (for a total of 1616), then give away 88, then give away 44, then give away 22, then give away 11.

Christopher wants to know how long it will take to get rid of his items using this technique.

Given a number, you must tell Christopher how many steps the technique takes to convert the number to one. For example, for the number 55 above, the number of steps needed would be 55.

입력

The input consists of one integer, NN (1≤N≤100 0001 \leq N \leq 100\ 000).

출력

Output the number of steps it takes for the input number to be converted to one.

예제2

  1. 예제 1

    입력
    5
    
    예상 출력
    5
    
  2. 예제 2

    입력
    8
    
    예상 출력
    3