I am getting mad errors when i try to implement this program i wrote to solve Leonhard Euler's conjecture. The error seems to be in the println
. Do you know what I'm doing wrong? (There are no errors before i run the program, the error messages appear after) What I'm implementing is fairly simple so I'm not quite sure why it is not cooperating.
p.s. I read on another website to assign the out message as a String object and print that String object, but that just adds another error message to the list.
public static void main(String[] args) {
BigInteger max = new BigInteger("Integer.MAX_VALUE");
// for(int a=0; a<max; a++)
for(BigInteger a=BigInteger.ZERO; a.compareTo(max)<=0; a=a.add(BigInteger.ONE)){
for(BigInteger b=BigInteger.ZERO; b.compareTo(max)<=0; b=b.add(BigInteger.ONE)){
for(BigInteger c=BigInteger.ZERO; c.compareTo(max)<=0; c=c.add(BigInteger.ONE)){
for(BigInteger d=BigInteger.ZERO; d.compareTo(max)<=0; d=d.add(BigInteger.ONE)){
// a^4
a=a.pow(4);
// b^4
b=b.pow(4);
// c^4
c=c.pow(4);
// d^4
d=d.pow(4);
// a+b+c
BigInteger sum = new BigInteger("a.add(b).add(c)");
// if( sum == d^4 )
int euler = sum.compareTo(d);
if( euler ==0)
{
System.out.println(a+"^4+"+b+"^4+"+c+"^4="+d+"^4");
}
}
}
}
}
}