I have this code:
public static int pow (int x, int n) {
if (n==0) return 1;
int t = pow (x, n/2);
if (n%2 == 0) {
return t*t;
} else {
return t*t*x;
}
}
public static void main(String[] args) {
System.out.println (pow (5, 2));
}
The problem with this method is that it will only work if the result is smaller than 2 billion. I need rewrite it so that the result is a BigInteger. Please Help :(