Inscription
This problem is a simple simulation. If it is a data input, then a simple loop can be implemented, but if the amount of data is large, the efficiency of the algorithm will be extremely low, so pruning can be used.code show as below
#include <iostream>
using namespace std;
int n;
int main()
{
int count=0;//记步数
cin>>n;
while(n!=1){
if(n%2==0)
n=n/2;
else
n=(3*n+1)/2;
count++;
}
cout<<count;
return 0;
}