Files
python/C++课程/习题训练/3N+1问题_1.cpp

17 lines
264 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, count = 0;
scanf("%d", &n);
while(n > 1)
{
if(n%2 == 1) n = n * 3 + 1;
else n /= 2;
count++;
}
printf("%d\n", count);
return 0;
}