#include<bits/stdc++.h>
using namespace std;
long long n,a[10005],cnt;
int main(){
    cin>>n;
    while(n!=1){
        a[cnt++]=n;
        if(n%2==0){
            n/=2;
        }
        else{
            n=n*3+1;
        }

    } 
    a[cnt]=1;
    for(int i=cnt;i>=0;i--){
        cout<<a[i]<<" ";
    }
    return 0;
}

0 comments

No comments so far...