I'm trying to solve this question using Java but can't seem to figure out what is wrong with my code.
Is the difference of 5^30000 and 6^123456 a multiple of 31?
public class fermat {
public static int fermat(int x, int y, int n){
return (int)(Math.pow(x,y)%n);
}
public static void main(String[] args) {
int result1=fermat(5,30000,31);
int result2=fermat(6,123456,31);
System.out.println(result1);
System.out.println(result2);
} // main
} // class Fermat
It returns 0.