D
Dexter
In a programming book, I found this recursive algorithm which always
returns 1 regardless of the value of the input parameter
==================
int collatz (int n) {
if (n == 1)
return 1;
else{
if ( n%2 == 1)
return collatz(3*n+1);
else
return collatz(n/2);
}
}
==================
The author of the book asserts its unproven that it will indeed always
return 1
returns 1 regardless of the value of the input parameter
==================
int collatz (int n) {
if (n == 1)
return 1;
else{
if ( n%2 == 1)
return collatz(3*n+1);
else
return collatz(n/2);
}
}
==================
The author of the book asserts its unproven that it will indeed always
return 1