euler 9
by Hensixteen
JavaScript
var a;
var b;
var c;
var sum;
var solved = false;
var leaveLoop = false;
for(a = 1; solved == false; a++) {
leaveLoop = false;
for(b = 1; leaveLoop == false; b++) {
c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
sum = (a+b+c);
if(sum == 1000) {
solved = true;
leaveLoop = true;
console.log(a + " * " + b + " * " + c + " = " + (a*b*c));
console.log(a + " + " + b + " + " + c + " = " + (a+b+c));
}
else if(sum > 1000) {
leaveLoop = true;
}
}
}