The last return statement executed in the factorial
function is return 1;
why does it return the right value and not 1 ?
#include <iostream>
using namespace std;
unsigned int factorial(unsigned int);
int main ()
{
unsigned int a=4;
cout<<factorial(a);
return 0;
}
unsigned int factorial(unsigned int a)
{
if (a==0)
return 1;
else
return a*(factorial(a-1));
}