/*
 *	This program tests the factorial funtion,
 *	and in the process, prints the first ten factorials
 */

main()
{
	int n, fac;
	int factorial();

			/*
			 * Set n equal to 1; loop until n is greater
			 * than 10, each time incrementing n by 1
			 */

	for (n = 1; n <= 10; ++n)
	  {
		fac = factorial(n);	/* Set fac to factorial of n */
		printf("%d! equals %d.\n", n, fac);	/* Print n and fac */
	      }
      }

/*
 * This function that calculates factorials
 */

int factorial(number)
	int number;
{
	int n, answer;

					/*
					 * Set n and answer to 1
					 * loop until n is greater
					 * than number, incrementing
					 * n by 1 each time.
					 */

	for (n = answer = 1; n <= number; ++n)
	  {
		answer *= n;	/* Multiply answer by n */
	      }

	return(answer);		/* Return the factorial of number */
      }
