Search found 1 match

by clearner
Sat Jun 21, 2008 9:39 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 320256

Re: 100

Hi, someone who can give me a hand, just don't know why it always show runtime error with my c program. Here is my codes:

#include <stdio.h>

int Q(int n)
{
int cyclelength=1;

while(n>1)
{
if((n%2)==1) {
n=3*n+1;
}
else n = n/2;
cyclelength++;
}
return cyclelength;
}

int main()
{
int ...

Go to advanced search