Created
September 19, 2018 11:10
-
-
Save Acesmndr/8e2aca02988d2ea99f79286b70ef4528 to your computer and use it in GitHub Desktop.
WCC W05::C01 Pythagorean triplet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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