- #include <stdio.h>
- int main()
- {
- int step = 0, N;
- scanf("%d", &N);
- while(N != 1)
- {
- N = N % 2 ? (3 * N + 1) / 2 : N / 2;
- step++;
- }
- printf("%d\\n", step);
- return 0;
- }
- //该片段来自于http://www.codesnippet.cn/detail/130520149558.html
来源: http://www.codesnippet.cn/detail/130520149558.html