Created
September 18, 2016 13:19
-
-
Save cds-amal/d1c6ef59009060b0d7b0521d2b1802db to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var values = [118080, 168480,202500]; | |
for (var a = 1; a < 100; a++) { | |
for (var b = a + 1; b < 100; b++) { | |
if (a + b > 180) break; | |
/* | |
* Start c at 1... | |
*/ | |
for (var c = 1; c < 100; c++) { | |
/* | |
* Constrain on sum | |
*/ | |
if (a + b + c === 180) | |
for (var v in values) { | |
if (values[v] === a * b * c) { | |
console.log(`triplet = (${a}, ${b}, ${c}) product: ${a*b*c} sum: ${a+b+c}`); | |
break; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment