I have just a little question: Why do I get the result of 25 if I calculat 13^30 mod 31 in java? The result should be 1. Thx for the answer in advance. p.s. I wrote the code on https://www.compilejava.net/
import java.lang.Math; 
public class HelloWorld
{
  public static void main(String[] args)
  {
    System.out.println(calculateModulo());
  }
  public static String calculateModulo(){
    String res = new String();
    for (int i = 1; i < 31; i++){   
      for (int j = 1; j < 31; j++){
          double var = Math.pow((double)i, (double)j);
         if (j == 30) {
            System.out.println("adding: "+i);
            res = res + "  " + i;
          } 
          if (var % 31 == 1) {
            System.out.println("The number " + i +" to the power of "+j +" modulo 31 results in "+var % 31);
            break;
          }
        }
    }
    System.out.println(Math.pow(13,30)+"         "+(Math.pow(13,30)%31)); // why is the output of this "2.619995643649945E33         25.0"
    return res;
  }
}
 
     
     
    