[CODE lang="java" title="Java"]package ProjectEuler9;
public class Main {
public static void main(String[] args) {
boolean isReady = false;
for (int a = 1; !isReady; a++) {
for (int b = 1; !isReady; b++) {
if ((int) Math.pow((int) Math.sqrt((int) Math.pow(a, 2) + (int) Math.pow(b, 2))) == (int) Math.pow(a, 2) + (int) Math.pow(b, 2)) {
if ((int) Math.sqrt((int) Math.pow(a, 2) + (int) Math.pow(b, 2)) + a + b == 1000) {
System.out.println((int) Math.sqrt((int) Math.pow(a, 2) + (int) Math.pow(b, 2))+" das ist c");
System.out.println(a +" das ist a");
System.out.println(b +" das ist b");
isReady = true;
}
}
}
}
}
}[/CODE]
was ich mir gedacht habe ist (√(a^2+b^2))^2 == a^2 +b^2 (Zeile 6)
public class Main {
public static void main(String[] args) {
boolean isReady = false;
for (int a = 1; !isReady; a++) {
for (int b = 1; !isReady; b++) {
if ((int) Math.pow((int) Math.sqrt((int) Math.pow(a, 2) + (int) Math.pow(b, 2))) == (int) Math.pow(a, 2) + (int) Math.pow(b, 2)) {
if ((int) Math.sqrt((int) Math.pow(a, 2) + (int) Math.pow(b, 2)) + a + b == 1000) {
System.out.println((int) Math.sqrt((int) Math.pow(a, 2) + (int) Math.pow(b, 2))+" das ist c");
System.out.println(a +" das ist a");
System.out.println(b +" das ist b");
isReady = true;
}
}
}
}
}
}[/CODE]
was ich mir gedacht habe ist (√(a^2+b^2))^2 == a^2 +b^2 (Zeile 6)