害死人不偿命的(3n+1)猜想 (15)
1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 5 int main(){ 6 7 int n; 8 while (cin >> n){ 9 int ans = 0; 10 while (n != 1){ 11 if (n % 2 == 0) 12 n /= 2; 13 else 14 n = (3 * n + 1)/2; 15 ans++; 16 } 17 cout << ans << endl; 18 } 19 20 //system("pause"); 21 return 0; 22 }