What the heck is gcd? I know GDP is Gross Domestic Product.
Anyway you\'ll want a conditional expression in your function or it will never stop recursing. Some people I know never stop recursing.
int myFactorial( int x)
{
if (x > 1)
x *= myFactorial( x - 1);
return x;
}
int main()
{
int y = 4;
cout << "factorial of " << y << " ... " << myFactorial(y) << endl;
return 0;
}
That should echo out 24 as the result. If you want to, put a \'cout\' in there to see each recursive call:
int myFactorial( int x)
{
cout << x << endl;
if (x > 1)
x *= myFactorial( x - 1);
return x;
}