Factorial
Completed
Read n (0–12) and print n!.
Input
One integer.
Output
n!
Example
Input
5
Output
120
Editor
C
Hints
Start the product at 1.
Solution explanation
12! is the largest factorial that fits in a 32-bit int.
Show solution
#include <stdio.h>
int main() {
int n;
int f = 1;
scanf("%d", &n);
for (int i = 2; i <= n; i++) {
f *= i;
}
printf("%d\n", f);
return 0;
}