#include <iostream>
using namespace std;
int main (void)
{
long long number;
int counter = 0;
cout << "Input a number: ";
cin >> number;
while (number != 1) {
if (number % 2 != 0) {
number = 3*number + 1;
cout<< number <<" ";
} else {
number /= 2;
cout<< number <<" ";
}
counter++;
if (counter % 5 == 0) {
cout<<endl;
}
}
cout<<endl<<"Total steps: "<<counter<<endl;
return 0;
}
验证角谷猜想
最新推荐文章于 2022-07-27 14:36:44 发布