#include<iostream>
using namespace std;
int countStep(int n) {
int i = 0;
while (n != 1) {
if (n % 2 == 0) {
n /= 2;
i++;
}
else if (n % 2 == 1) {
n = (3 * n + 1) / 2;
i++;
}
}
return i;
}
int main()
{
int n, i;
cin >> n;
i = countStep(n);
cout << i;
}
1001害死人不偿命的3n+1猜想
最新推荐文章于 2024-11-01 17:00:11 发布