You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
334 B

#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;
}