Skip to content

Instantly share code, notes, and snippets.

@cds-amal
Created September 18, 2016 13:19
Show Gist options
  • Save cds-amal/d1c6ef59009060b0d7b0521d2b1802db to your computer and use it in GitHub Desktop.
Save cds-amal/d1c6ef59009060b0d7b0521d2b1802db to your computer and use it in GitHub Desktop.
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