Hi,
I'm trying to find the number abcd such that a^b + c^d = abcd
however, I'm running the code fine, but it's going to my second if statement, the one that's supposed to tell me that there's no solution. Am I doing something wrong or is there truly no solution?
public class numbertwo {
public static void main(String[] args) {
double first = 0;
double second = 0;
double third = 0;
double fourth = 0;
double d = 1;
while (d != 0 && first < 9) {
first++;
while (d != 0 && second < 9) {
second++;
while (d != 0 && third < 9) {
third++;
while (d != 0 && fourth < 9) {
fourth++;
d = Math.pow(first,second) + Math.pow(third,fourth) - first * 1000 - second * 100 - third * 10 - fourth;
}
d = Math.pow(first,second) + Math.pow(third,fourth) - first * 1000 - second * 100 - third * 10 - fourth;
}
d = Math.pow(first,second) + Math.pow(third,fourth) - first * 1000 - second * 100 - third * 10 - fourth;
}
d = Math.pow(first,second) + Math.pow(third,fourth) - first * 1000 - second * 100 - third * 10 - fourth;
}
if ( d == 0 ) {
System.out.print("Win");
System.out.println(first * 1000 + second * 100 + third * 10 + fourth);
}
if ( d != 0 ) {
System.out.print("Bleh noob");
d = 0;
}
}
}