#include <iostream>
using namespace std;
int main(){
int n;
cin>>n;
if(n<1001&&n>0)
{
int step=0;
while(n!=1){
if (n%2==0)n=n/2;
else n=(3*n+1)/2;
step++;}
cout<<step;
}
else
cout<<"error";
return 0;
}
pat 乙级 1001 害死人不偿命的(3n+1)猜想 (15分)
最新推荐文章于 2024-09-04 21:29:26 发布