my program produce desired output but i am getting wrong anwer from u

import java.util.Scanner ;
class factorial
{
public static void main(String [] args)
{
Scanner inp = new Scanner(System.in);

     int T= inp.nextInt();
     int n;
     int fact=1;
     int i=0;
     int j=1;
     while(i<T)
     {
       n=inp.nextInt();
       fact=1;
       for(j=1;j<=n;j++)
       {
       	fact=fact*j;
       }
       System.out.println(fact);
       i++;

     }
 }
}

pls provide d link to d question !

you are getting wrong answer because of overflowing.Your code works only if n<=16 and if n>16 your code is printing negative values

thanks can u help me in solving this problem

you can solve this using biginteger ,see this code https://www.codechef.com/viewsolution/14301522

okay i will try thanks for ur support

//