Google Code jam kickStart Problem A : Huge Number

codejam
google
problem

#1

Problem Link

Can any one please tell it is giving wrong answer but it is working for sample test case
My Solution

/*
###### ##### ###### ######

# # # # # # # #

# # # # # # ## # # ## #

# # # # # # # # #

# # # # # # # # #

/
import java.util.
;
import java.lang.;
import java.io.
;
import java.math.*;
class hugenumber {
public static void main(String args[] ) throws Exception {
Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
PrintStream p = System.out;
int t =scan.nextInt();
int i=1;
while(t–>0){

        int a =scan.nextInt();
        int n =scan.nextInt();
        int d =scan.nextInt();
        BigInteger fact = factorial(n);
        BigInteger bi1 = new BigInteger(Integer.toString(a));
        BigInteger bi2 = new BigInteger(Integer.toString(d));
        BigInteger bi3 = bi1.modPow(fact, bi2);
        p.println("Case #" + i + ": " +bi3);
        i++;
    }
    
}
static BigInteger factorial(int n){
    BigInteger fact= BigInteger.ONE;
    int factorialNo = 100;

    for (int i = 2; i <= factorialNo; i++){
        fact = fact.multiply(new BigInteger(String.valueOf(i)));
    }
    return fact;
}

}


#2

y were u looping till 100 in factorial method?


#3

that was silly how did i miss that
Thanks @beginner_1111