Factorial
Completed
Read n (0–20) and print n! using unsigned long long.
Input
One integer.
Output
n!
Example
Input
5
Output
120
Editor
C++
Hints
20! fits in 64 bits.
Solution explanation
unsigned long long holds values up to about 1.8 × 10¹⁹.
Show solution
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
unsigned long long f = 1;
for (int i = 2; i <= n; i++) f *= i;
cout << f << "\n";
return 0;
}