#include <cstdio>

void f(int n)
{
    if(n%2!=0 && n!=1)
        f(3*n+1);
    else if(n!=1)
        f(n/2);
    printf("%d\n",n);
}

int main()
{
    int n;
    scanf("%d",&n);
    f(n);
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: