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.

20 lines
368 B

#include <bits/stdc++.h>
using namespace std;
const int N = 210;
vector<int> v;
int n;
int main() {
cin >> n;
while (n > 1) {
v.push_back(n);
if (n & 1)
n = n * 3 + 1;
else
n = n >> 1;
}
v.push_back(1);
for (int i = v.size() - 1; i >= 0; i--) printf("%d ", v[i]);
return 0;
}