Header Ads

Learn Together, Stay Connected.

ColatzConjecture Related-C


#include <stdio.h>

int main()
{
   int n,count=0;
  
   scanf("%d",&n);

   while(n>1)
       {
          if(n&1) n=3*n+1;
          
          else n/=2;
        count++;
        
       }
   printf("%d\n",count);

   return 0;

}

No comments

Theme images by Dizzo. Powered by Blogger.