#include <iostream>
using namespace std;

int collatz(int N) {
    if (N == 1) return 1;
    else if (N % 2 == 0) {
        cout << N << " ";
        return collatz(N / 2);
    }
    else {
        cout << N << " ";
        return collatz(3 * N + 1);
    }
}

int main() {
    int N;
    cout << "\nEnter a positive number for N:\n";
    while (cin >> N) {
        cout << collatz(N);
    }
}