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

水题。

#include"iostream"
using namespace std;
int main() {
    int n,ans = 0;
    cin>>n;
    while(n != 1) {
        if(n % 2==0) n/=2;
        else n=(3*n+1)/2;
        ans++;
    }
    cout<<ans;
    return 0;
}

 

posted @ 2020-02-14 20:30  tangq123  阅读(132)  评论(0编辑  收藏  举报