Skip to content

Instantly share code, notes, and snippets.

@gkucmierz
Created May 10, 2023 15:01
Show Gist options
  • Save gkucmierz/b5db360aa8401e231ce48dda32d5c0c2 to your computer and use it in GitHub Desktop.
Save gkucmierz/b5db360aa8401e231ce48dda32d5c0c2 to your computer and use it in GitHub Desktop.
// Eulers bricks (brute force)
const check = (a, b, c) => {
if (Math.hypot(a, b) % 1 !== 0) return false;
if (Math.hypot(b, c) % 1 !== 0) return false;
if (Math.hypot(c, a) % 1 !== 0) return false;
return Math.hypot(a, b, c);
}
const MAX = 1e3;
for (let a = 1; a < MAX; ++a) {
for (let b = 1; b < MAX; ++b) {
for (let c = 1; c < MAX; ++c) {
const res = check(a, b, c);
if (res !== false) {
console.log(a, b, c, res);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment