Originally Posted by

**Kernel Sanders**
The third condition is never used. If m>0 the second will be evaluated whether n>0 or not. You also need to return ack(whatever) instead of just invoking it. As is the value is never used or returned, just computed and thrown out

My mistake on the missing return bit. I'm not sure why I overlooked that... Anyway, I've updated the conditions of the second else if - they should now properly match the wikipedia entry.

Code:

//implementation of the recursive ackerman function
int ack(int m, int n)
{
if (m == 0){
return n+1;
}
else if((m > 0) && (n == 0)){
return ack(m-1, 1);
}
else if((m > 0) && (n > 0)){
return ack(m-1, ack(m, n-1));
}
}//end ack