Skip to content

Instantly share code, notes, and snippets.

@kand
Created May 18, 2016 17:39
Show Gist options
  • Save kand/3c424308fd1ee406b861875b614e63df to your computer and use it in GitHub Desktop.
Save kand/3c424308fd1ee406b861875b614e63df to your computer and use it in GitHub Desktop.
var testPalindromicity = function (num) {
var strNum = '' + num;
for (var i = 0; i <= strNum.length / 2; i++) {
if (strNum[i] !== strNum[strNum.length - i - 1]) {
return false;
}
}
return true;
};
module.exports = {
solution: function () {
var largest = 0;
for (var i = 100; i <= 999; i++) {
for (var j = 100; j <= 999; j++) {
var product = i * j;
if (product > largest && testPalindromicity(product)) {
largest = product;
}
}
}
console.log(largest);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment