Skip to content

Instantly share code, notes, and snippets.

@Acesmndr
Created September 19, 2018 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Acesmndr/8e2aca02988d2ea99f79286b70ef4528 to your computer and use it in GitHub Desktop.
Save Acesmndr/8e2aca02988d2ea99f79286b70ef4528 to your computer and use it in GitHub Desktop.
WCC W05::C01 Pythagorean triplet
for(let c = 500; c > 0; c--) {
let b = c - 1;
for(; b > 0; b--) {
let a = b - 1;
for(; a > 0; a--) {
if (((a**2 + b**2) === c**2) && (a + b + c === 1000)){
console.log(`The Pythagorian Triplets are ${a}, ${b} and ${c}.`);
break;
}
}
}
}
// The Pythagorian Triplets are 200, 375 and 425.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment