8

h2022027 2023-10-14 19:42:07

#include <bits/stdc++.h> using namespace std;

long long a[110], idx; int n;

int main() { cin >> n; while (n != 1) { a[++idx] = n; if (n % 2 == 0) n /= 2; else n = n * 3 + 1; } a[++idx] = 1; for (int i = idx; i >= 1; i--) cout << a[i] << ' '; cout << endl; return 0; }