let max = -Infinity;
for (let i=100; i<1000; i++) {
// it's mirror
for (let j=i; j<1000; j++) {
let num = i*j;
if (isPlalindrome(num)) {
max = Math.max(max, num);
}
}
}
console.log(max);
function isPlalindrome(num) {
let str = String(num);
let len = str.length;
let mid = Math.floor(len/2);
for (let i=0; i<mid; i++) {
if (str[i] !== str[len-i-1]) {
return false;
}
}
return true;
}
This repository has been archived by the owner on Nov 26, 2018. It is now read-only.