Created
April 30, 2015 22:00
-
-
Save masterots/df5d7512d96137f8148b to your computer and use it in GitHub Desktop.
Project Euler - largest palindrome
This file contains 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
function largestPalindrome(lowNum, highNum) { | |
var max = 0; | |
for (var i = highNum; i >= lowNum; i--) { | |
for (var j = i; j >= lowNum; j--) { | |
var mul = j * i; | |
if (isPalindrome(mul) && mul > max) { | |
max = i * j; | |
} | |
} | |
} | |
return max; | |
} | |
function isPalindrome(i) { | |
i = '' + i; | |
return i === i.split("").reverse().join(""); | |
} | |
console.log(largestPalindrome(100,999)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment