Search found 1 match

by khiosa
Tue Jun 08, 2010 9:12 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 320772

Re: The 3n + 1 problem

I cannot figure out why my code is wrong. Can anyone please help? C++
#include <iostream>
#include <algorithm>

inline int length(unsigned int n)
{
unsigned int length = 1;
while( n != 1)
{
length++;

if((n%2) == 1)
n = 3*n+1;
else
n = n/2;
}

return length;
}
int main()
{
unsigned int ...

Go to advanced search