/* 
	Simple factorial program
	This program takes an integer from the user and calculates the factorial.

	by Ismail Ari, 02 Feb 2007
*/

#include <stdio.h>

int factorial(int n)
/* takes the number and returns its factorial */
{
	int i;
	int result;

	result = 1;
	
	for(i=1; i<=n; i++)
		result *= i;

	return result;
}


int main()
/* the main function */
{
	int num, res;

	printf("Enter the number: ");
	scanf("%d", &num);

	res = factorial(num); /* calculate the factorial */

	printf("The factorial is %d",res);

	return 0;
}