small factorials

Even though the output is correct for the given input (4 1 2 5 3), “wrong answer” is being displayed upon submission.Can someone help with this?

import java.util.Scanner;

class Test
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
int fact=1;
while(t–>0)
{
int num=sc.nextInt();
if(num==1 || num==0)
System.out.println(fact);
else
{
for(int i=2;i<=num;i++)
{
fact=fact*i;
}
System.out.println(fact);
fact=1;
}
}
}
}

This is a case of overflow. int cannot contain larger numbers. Maybe u need to use BigInteger or other manipulation to get AC.