// recursiveFactorial.cc P. Conrad 09/23/05
// compute factorial with recursion

#include <iostream>
using namespace std;


int factorial(int x)
{
  // recursive factorial

  if (x == 0)
    {
#ifdef DEBUG
      cout << "I'm in the if x==0 part"  << endl;
#endif
      return 1;
    }
  else
    {
#ifdef DEBUG
      cout << "I'm in the else part, x = " << x << endl;
#endif
      return x * factorial(x-1); 
    }
}

int main(void)
{
  int x;

  cout << "Enter x: ";
  cin >> x;

  cout << "x! is : " << factorial(x) << endl;

  return 0;

}

