FCTRL2 getting wrong answer

import java.util.*;

class RainBowa {

public static void main(String a[]) {
    int n, t, fact;
    Scanner sc = new Scanner(System.in);
    t = sc.nextInt();
    int ar[] = new int[t];

    for (int i = 0; i < t; i++) {
        ar[i] = sc.nextInt();
    }

    for (int i = 0; i < t; i++) {
        fact = 1;
        for (int j = ar[i]; j >= 1; j--) {
            fact = fact * j;
        }
        System.out.println(fact);
    }

}

}

You cannot hold something as big as 100! in typical data types. Please read about Big Integer, and maximum limits of int and long data types in JAVA.

i also stuck in this problem today . Then i learn about BigInteger , and it helps . You cant hold factorial of 50+ in int (limitation of range) .

Little hint : you have to change int fact to BigInteger fact

hope it helps

//