Skip to content

Instantly share code, notes, and snippets.

@egeozcan egeozcan/solution.js
Last active Sep 30, 2015

Embed
What would you like to do?
Project Euler Problem 4 - JavaScript Solution
console.time("p");
console.log(function () {
var x, y, z, i = 999, latestPalindrome = 0, palindromeDivider = 0;
for (x = 9; x > 0; x--) {
for (y = 9; y >= 0; y--) {
for (z = 9; z >= 0; z--) {
latestPalindrome = 100001 * x + 10010 * y + 1100 * z;
for (i = 999; i >= 100; i--) {
if (latestPalindrome % i === 0) {
palindromeDivider = latestPalindrome / i
if(palindromeDivider > 999)break;
if (palindromeDivider >= 100) {
return [
"our palindrome is ",
palindromeDivider, " x ", i,
" = ", latestPalindrome ].join("");
}
}
}
}
}
}
}());
console.timeEnd("p");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.