Search found 1 match

by villainoftime
Sat Jun 21, 2014 8:28 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 304423

Re: 100

Why am I getting wrong answer, please?? #include<stdio.h> int collatz(int n); int cyclecounter(int n); int main() { int i, j, cycle, MAX; while(scanf("%d %d", &i, &j)==2) { MAX=0; int n=i, p; if(i>j) p=-1; else p=1; for(; n!=j; n+=p) { int cycle=cyclecounter(n); if(MAX<cycle) MAX=c...

Go to advanced search