Blame view

P57474_en/S003-AC.cc 237 Bytes
Imanol-Mikel Barba Sabariego authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

using namespace std;

int factorial(int n)
{
	if(!n)
	{
		return 1;
	}
	int res = n;
	for(int i = n-1; i > 0; i--)
	{
		res *= i;
	}
	return res;
}
int main()
{
	int a;
	cin >> a;
	cout << factorial(a);
	return 0;
}