Collatz Algorithm

The Collatz Algorithm, also known as the Collatz conjecture or the 3n + 1 conjecture, is a mathematical algorithm that generates a sequence of numbers based on a simple set of rules. It was formulated in 1937 by the German mathematician Lothar Collatz, and despite its simplicity, it remains an unsolved problem in mathematics. The conjecture is based on the following rules: start with any positive integer n, and if n is even, divide it by 2 (n/2), but if n is odd, multiply it by 3 and add 1 (3n + 1). Repeat this process for each new value of n, and the conjecture states that no matter what initial value of n is chosen, the sequence will eventually reach the number 1. Although the Collatz Algorithm appears simple, it has proven to be quite complex and has eluded mathematicians for decades. Despite extensive computational evidence supporting the conjecture, a formal proof has not been found. The algorithm has been tested for initial values up to 2^60, and in each case, the sequence eventually reaches 1. The lack of a proof has led to the Collatz Algorithm becoming a popular topic in the field of mathematical conjectures and unsolved problems. The algorithm's simplicity and intrigue have also made it an appealing subject for recreational mathematics, computer programming, and mathematical education.
/*
collatz conjecture: a series for a number n in which if n even then the next number is n/2 ,but if n is odd then the next number is 3n+1.
this series continues till it reaches 1*/

#include<stdio.h>
int main()
{
    int n,curr_no;   
    scanf("%d",&n);     //input number 
    curr_no=n;        //curr_no stores input number n   
    while(curr_no!=1)     //loop till series reaches 1
    {
        if(curr_no%2==0)      //condition   for even number
        {
            curr_no=curr_no/2;
            printf("%d->",curr_no);
        }    
        else 
        {
            curr_no=(curr_no*3)+1;      //condition for odd number
            printf("%d->",curr_no);
        }
    }
    printf("1");
    return 0;
}

LANGUAGE:

DARK MODE: