You are asked to calculate factorials of some small positive integers.
Input
An integer T, denoting the number of testcases, followed by T lines, each containing a single integer N.
An integer T, denoting the number of testcases, followed by T lines, each containing a single integer N.
Output
For each integer N given at input, output a single line the value of N!
For each integer N given at input, output a single line the value of N!
Input Constraint
1 <= T <= 100
1 <= N <= 100
1 <= N <= 100
import java.math.BigInteger;
import java.util.Scanner;
public class Factorial {
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
int n=scn.nextInt();
int [] arr= new int[n];
for(int i=0;i<arr.length;i++)
{
arr[i]+=scn.nextInt();
}
for(int m:arr)
{
BigInteger fact = fact(m);
System.out.println("fact("+m+") = " + fact);
}
}
private static BigInteger fact(long n) {
BigInteger result = BigInteger.ONE;
for (long i = 2; i <= n; i++)
result = result.multiply(BigInteger.valueOf(i));
return result;
}
}