Search found 1 match

by tuxskywalker
Thu Oct 13, 2011 12:54 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 320000

3n + 1

Rather a newbie at ANSI C. :oops:

I submitted this code for 3n+1 problem and get WA. :cry: Any suggestions?

#include <stdio.h>

int cycle(int n)
{
int count = 1;
while(n != 1)
{
if(n%2==0){ n /= 2; }
else{ n = (3*n)+1; }
++count;
}
return count;
}


int main()
{

int i,a,b;
scanf("%d %d ...

Go to advanced search