Search found 2 matches

by msq
Fri Jun 09, 2006 8:42 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 318350

thx emotional blind...
Ii still don't know why I usen do while instead of while do. Anyway my prog is accepted. It runs for 3.6s so now I will try to speed it up :)
by msq
Thu Jun 08, 2006 7:40 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 318350


#include <iostream>

using namespace std;

void swap (unsigned long &a, unsigned long &b) {
unsigned long temp;
temp = a;
a = b;
b = temp;
}

unsigned long cycle_length (unsigned long n) {
unsigned long length=1;
do {
length++;
if (n%2!=0)
n = 3*n+1;
else
n /= 2;
} while (n!=1 ...

Go to advanced search