22 lines
355 B
C++
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;
|
|
} |