Created
May 29, 2010 19:20
-
-
Save clauswitt/418472 to your computer and use it in GitHub Desktop.
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
var sys = require('sys'); | |
var Euler4 = function() { | |
var isPalindromicNumber = function(num) { | |
var digitString = num.toString(); | |
var reverseString = digitString.split('').reverse().join(''); | |
return (digitString==reverseString); | |
} | |
var getResult = function() { | |
result = 0; | |
res = 0; | |
for(var i=999;i>99;i--) { | |
for(var j=999;j>99;j--) { | |
if(j<i) break; | |
res = j*i; | |
if(isPalindromicNumber(res)) { | |
if(res>result) { | |
result = res; | |
}; | |
break; | |
} | |
} | |
} | |
sys.puts('Result: ' + result); | |
} | |
getResult() | |
}; | |
new Euler4(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment