/*
Write a function to return by its return statement n! 
(the factorial of n), where n is a positive integer.
Write also a driver program to test the function.
Input: a positive integer n.
Output: the product of the integers from 1 to n; i.e. n!.
*/

#include <iostream>
using namespace std;

int factorial(int n);

int main() 
{
	int n;
	cout << "Enter an integer: ";
	cin >> n; 
	cout << factorial(n) << endl;
	return 0;
}

// The definition of the function
int factorial(int n) 
{
	int f = 1;
	for (int i = 1; i <= n; i++)
		f *= i; // f = f * i;
	return  f;
}
