Problem
Write a program to find the factorial value of any number entered by the user.
Input
The first line contains an integer T, the total number of testcases. Then T lines follow, each line contains an integer N.
Output
For each test case, display the factorial of the given number N in a new line.
Constraints
- 1 ≤ T ≤ 1000
- 0 ≤ N ≤ 20
Example
Input 3 3 4 5Output
6 24 120
Program :
#include<stdio.h>
int main()
{
int t,a,fact,i;
scanf("%d",&t);
for(i=0;i<t;i++)
{
fact=1;
scanf("%d",&a);
for(int i=1;i<=a;i++)
{
fact=fact*i;
}
printf("%d\n",fact);
}
}
0 Comments