Skip to content

Instantly share code, notes, and snippets.

@JossWhittle
Created August 10, 2012 00:45
Show Gist options
  • Save JossWhittle/3309682 to your computer and use it in GitHub Desktop.
Save JossWhittle/3309682 to your computer and use it in GitHub Desktop.
public void p9() {
for (int a = 1; a < 1000; a++) {
for (int b = a + 1; b < 1000; b++) {
double c = sqrt(Math.pow(a, 2) + Math.pow(b, 2), 1);
if (((int)c == c) && (a + b + c == 1000)) {
System.out.println((int)(a*b*c));
}
}
}
}
public double sqrt(double n, double g) {
double gx = ((n/g) + g)/2;
if (gx == g) { return g; }
return sqrt(n, gx);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment