Originally Posted by
Sparrowhawk
Having no returns anywhere in the program is whats hanging me up, and the fact that you can't call it like you can with a return type because you can't make the call I noted in the original post when m & n are >0.
Compare:
Code:
int factorial(int n)
{
assert(n >= 0 && "Factorial operand must be non-negative.");
if (n == 0)
{
return 1;
}
else
{
return n * factorial(n - 1);
}
}
to:
Code:
void factorial(int n, int& result)
{
assert(n >= 0 && "Factorial operand must be non-negative.");
if (n == 0)
{
result = 1;
}
else
{
int temp;
factorial(n - 1, temp);
result = n * temp;
}
}