I am trying to repeat the search for a counterexample for Euler's conjecture. I need to find five numbers such that a1^5+a2^5+3^5+a4^5 =a5^5
. The smallest counterexample is 27^5+84^5+110^5+133^5=144^5. I think I am looping over each number and make sure that the numbers are ordered, however, I don't get the expected result. Please point my error.
public class Euler {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int a1 = 1; //greatest
int a2 = 1;
int a3 = 1;
int a4 = 1;
boolean solved = false;
while (!solved) {
if (a3 >= a4) { //major progress!!!
System.out.println("values are " + a1 + " " + a2 + " " + a3 + " " + a4 + " " + solved);
a4++;
a3 = 1;
a2 = 1;
a1 = 1;
}else if(a2 >= a3) {
a3++;
a2 = 1;
a1 = 1;
} else if(a1 >= a2) {
a2++;
a1 = 1;
}
solved = antiEuler(a1, a2, a3, a4);//Check conjencture
a1++;
}
}
public static boolean antiEuler(int a1, int a2, int a3, int a4) {//
double a5 = Math.pow(Math.sqrt(Math.pow(a1, 5) + Math.pow(a2, 5) + Math.pow(a3, 5) + Math.pow(a4, 5)), 0.2);
double a6 = Math.floor(a5);
if (a6 == a5) {
System.out.println("Done!");
System.out.println(a1+" "+a2+" "+a3 +" "+a4+" "+a5);
return true;
} else {
return false;
}
}
}