#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    printf("Yugeon Collatz v2.0> Please input only the number\n");
    long long a;
    scanf("%lld", &a);
    if(a <= 0) 
    {
        printf("Error> Positive integers only!\n");
        return 0;
    }

    printf("Starting Collatz simulation for: %lld\n", a);
    long long as = a;
    
    long long mv = a;
    int ec = 0;
    int oc = 0;

    printf("%lld>", as);
    for(int i = 0; ; i++)
    {
        if(as == 1)
        {
            printf("\n\n=== Simulation Report ===\n");
            printf("Target: %lld ended at step %d, Collatz proved\n", a, i);
            printf("Peak value reached: %lld\n", mv);
            printf("Even steps (/2): %d times\n", ec);
            printf("Odd steps (*3+1): %d times\n", oc);
            printf("================================\n");
            break;
        }
        else if(as % 2 == 0)
        {
            as /= 2;
            ec++; 
        }
        else
        {
            as = as * 3 + 1;
            oc++;  
        }
        
        if(as > mv) 
        {
            mv = as;
        }
        
        printf("%lld>", as);
    }
    return 0;
}

Embed on website

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