# Google Code jam kickStart Problem A : Huge Number

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 {
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;
}
``````

}

y were u looping till 100 in factorial method?

that was silly how did i miss that
Thanks @beginner_1111