Help me in solving FCTRL2 problem

My issue

why it not accepting the correct code

My code

// We have populated the solutions for the 10 easiest problems for your support.
// Click on the SUBMIT button to make a submission to this problem.

/**import java.util.*;
import java.lang.*;
import java.math.*;

// Name of the class has to be "Main" only if the class is public. 
class Codechef
{
    public static long factorial(long n){
        if(n==0){
            return 1;
        }
            return n*factorial(n-1);

    }
	public static void main (String[] args) throws java.lang.Exception
	{ 
	    Scanner sc = new Scanner(System.in);
	    long n,f,t;
	    t=sc.nextInt();
	     while(t-->0){
	         n=sc.nextInt();
	         f=factorial(n);
	         System.out.println(f);
	     }
	}
}*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

class Codechef {
    public static long factorial(long n) {
        if (n == 0) {
            return 1;
        }
        return n * factorial(n - 1);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());
        
        while (t-- > 0) {
            long n = Long.parseLong(br.readLine());
            long f = factorial(n);
            System.out.println(f);
        }
    }
}





Problem Link: FCTRL2 Problem - CodeChef

@rt1766285
Because of larger value of n , whose factorial can not be stored in any data type.
U have to store the result in array or string .
Plzz refer the following solution for better understanding of the logic.

// We have populated the solutions for the 10 easiest problems for your support.
// Click on the SUBMIT button to make a submission to this problem.

import java.util.*;
import java.lang.*;
import java.math.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
             Scanner sc = new Scanner(System.in);
             int t = sc.nextInt();
            while(t --> 0)
            {
                int n = sc.nextInt();
                BigInteger fact = new BigInteger("1");
                for(int i = 2; i <= n; i++)
                fact = fact.multiply(BigInteger.valueOf(i));
                System.out.println(fact);
            }
	    
	}
}