The textbook asks, why might Factorial(0) return 0, and to be honest I have no clue. The call trace would look like:Code:int Factorial(int n)
{
if(n == 1){
return 1;
}
else{
return n * Factorial(n -1);
}
}
Facorial(0) = 0 * Factorial(-1)
= 0* (-1) * Factorial(-2)...
it would just go into an infinite regress.
The only way I see it returning 0, if it runs out of resources, and somehow returns a 0, or grabs some piece of memory, which could have been a 0.
Any other possibilities?
Thanks