Files
python/TangDou/KaoShi/TangDou_3.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

22 lines
355 B
C++

#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
cin >> n;
while (1) {
if (n == 1) break;
if (n % 2 == 0) {
n /= 2;
printf("%d\n", n);
}
else if (n % 2 == 1) {
n = n * 3 + 1;
printf("%d\n", n);
}
}
return 0;
}