Subscribe Us

Responsive Advertisement

Advertisement

URI Online Judge | 1441 Hailstone Sequences solution in c

 

uri 1441 solution in c

by ujjal roy


#include<stdio.h>


main()

{

    int h;

    while(scanf("%d",&h)!=EOF)

    {


        if(h==0) break;

         int max=h;

        while(h!=1)

        {


        if(h%2==0) h=h/2;

        else h=3*h+1;

        if(h>max) max=h;

        }


       printf("%d\n",max);


    }

    return 0;

}


Post a Comment

0 Comments