C++ 实现角谷猜想算法 - 详细步骤解析
#include
int main() { int N; cin >> N;
while (N != 1) {
if (N % 2 == 0) {
cout << N << '/2=' << N / 2 << endl;
N /= 2;
} else {
cout << N << '*3+1=' << N * 3 + 1 << endl;
N = N * 3 + 1;
}
}
cout << 'End' << endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/nrbJ 著作权归作者所有。请勿转载和采集!