Search found 2 matches

by Absum
Thu Mar 13, 2008 7:46 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 320024

Thanks, finally figured it out and that case was one of two logical errors in my code. The other was in the for loop.
by Absum
Wed Mar 12, 2008 3:37 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 320024

I have a problem, my code looks like this:
#include <stdio.h>

int getiterations(int i) {
int c = 1;

while (i > 1) {
if (i % 2 != 0)
i = (3 * i) + 1;
else
i = i / 2.0;
c++;
if (c == 2) {
/* Do stuff */
}
}
return c;
}


int main(int argc, char *argv[]) {
while (!feof(stdin)) {
int i ...

Go to advanced search