Read a value N. Calculate and write its corresponding factorial.
Factorial of N = N * (N-1) * (N-2) * (N-3) * ... * 1.
Input
The input contains an integer value N (0 < N < 13).
Output
The output contains an integer value corresponding to the factorial of N.
Input Sample | Output Sample |
4
|
24
|
Solution using C :
#include <stdio.h>
int main() {
int n,s=1;
scanf("%d",&n);
while(n>0)
{
s *= n;
n--;
}
printf("%d\n",s);
return 0;
}
Comments
Post a Comment