Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save blentz100/1def183a39d9566936e5080d3d41d275 to your computer and use it in GitHub Desktop.
Save blentz100/1def183a39d9566936e5080d3d41d275 to your computer and use it in GitHub Desktop.
Problem 9: Special Pythagorean triplet
// 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);
@mabolen
Copy link

mabolen commented May 6, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment