Created
May 6, 2022 00:06
-
-
Save blentz100/1def183a39d9566936e5080d3d41d275 to your computer and use it in GitHub Desktop.
Problem 9: Special 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
// Problem 9: Special Pythagorean triplet | |
// https://www.freecodecamp.org/learn/coding-interview-prep/project-euler/problem-9-special-pythagorean-triplet | |
function specialPythagoreanTriplet(n) { | |
let sumOfabc = n; | |
/* | |
a b c | |
1 2 3 | |
2 3 4 | |
3 4 5 | |
4 5 6 | |
5 6 7 | |
6 7 8 | |
7 8 9 | |
*/ | |
return 60; | |
} | |
specialPythagoreanTriplet(12); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Known logic:
a < b < c < n
a + b + c === n (a === n - b - c etc.)
a** + b**=== c** // this must be true to be Pythagorean!
return a * b * c //return must be product of all three variables
How do we find a b c if value of one depends on the other? Last one would be something like c = n - b - a but how do we get a and b?