1001 害死人不偿命的(3n+1)猜想(15分)

#include <iostream>
using namespace std;

int main()
{
    int n,step=0;
    cin>>n;
    while(n!=1)
    {
        if(n%2==0)
            n=n/2;
        else
            n=(3*n+1)/2;
        step++;
    }
    
    cout<<step<<endl;
    return 0;
}
posted @ 2020-01-17 15:59  QRain  阅读(134)  评论(0编辑  收藏  举报