Skip to content

Instantly share code, notes, and snippets.

@afonsomatos
Last active August 29, 2015 14:24
Show Gist options
  • Save afonsomatos/9497c32f92c04e1cc948 to your computer and use it in GitHub Desktop.
Save afonsomatos/9497c32f92c04e1cc948 to your computer and use it in GitHub Desktop.
Benjamin's challenge
"use strict";
let x = 101;
// a^2 + b^2 + c^2 + d^2 = 101
// Loop a
for (let a = 0; a < x; ++a) {
// Loop b
for (let b = 0; b < a; ++b) {
// Loop c
for (let c = 0; c < b; ++c) {
// Loop d
for (let d = 0; d < c; ++d) {
// Check result
if (a*a+b*b+c*c+d*d === x) {
console.log("Gilad" + a + b + c + d + "@tipranks.com");
process.exit(0);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment