/* factorial9.cpp is a driver program to test the Factorial function
 *
 *******************************************************************/

#include <iostream.h>      	     // cin, cout, <<, >>

int Factorial(int n);

int main()
{
	cout << "To compute n!, enter n: ";
   int theNumber;
	cin >> theNumber;

	cout << theNumber << "! = "
        << Factorial(theNumber) << endl;

   return 0;
}

/*** Insert the #include directive and the definition of
     Factorial() from Figure 3.8 here. ***/

/* Factorial computes the factorial of a nonnegative integer. 
 *     
 * Receive:      n, an integer
 * Precondition: n is nonnegative
 * Return:       n!
 *************************************************************/

#include <cassert>             // assert()

int Factorial(int n)
{
   assert(n >= 0);

   int product = 1;

   for (int count = 2; count <= n; count++)
      product *= count;

   return product;
}


