#include<iostream> using namespace std; int main() { int n; int step = 0; cin >> n; while(n != 1) { if(n % 2 == 1) { n = (3*n+1)/2; step++; } else { n = n/2; step++; } } cout << step <<endl; return 0; }
原文:https://www.cnblogs.com/zhangqiling/p/12054725.html