TechoSagar: Factorial

Search

Google Alert - jobs

Factorial

Calculate the factorial for a given number.
Input:
The first line contains an integer 'T' denoting the total number of test cases. In each test cases, it contains an integer 'N'.

Output:
In each seperate line output the answer to the problem.

 
Constraints:
1<=T<=19
0<=N<=18

Example:
Input:
1
1
Output:
1
Your Code
#include<iostream>

using namespace std;

int main()
{
int t;
cin>>t;
while(t--)
{
int n, i;
long int fact=1;
cin>>n;
for(i=1; i<=n; i++)
  fact=fact*i;
}
cout<<fact<<endl;
}
return 0;
}

Follow us

Follow Bijendra Kumar on Facebook