Skip to content

Instantly share code, notes, and snippets.

@MuddyBootsCode
Created April 28, 2022 17:44
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 MuddyBootsCode/05fa26c76492d189816dbb191fe0535a to your computer and use it in GitHub Desktop.
Save MuddyBootsCode/05fa26c76492d189816dbb191fe0535a to your computer and use it in GitHub Desktop.
function specialPythagoreanTriplet(n) {
let solution = 0;
for(let a = 1; a < n / 2; a++){
for(let b = a; b < n; b++){
let c = Math.sqrt(a **2 + b **2);
if(Number.isInteger(c) && a + b + c === n){
solution = a * b * c;
}
}
}
return solution;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment