Created
August 7, 2018 19:03
-
-
Save DiegoPinho/7af942a0e7ca987bc1e0d37819ffaf98 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
function findMajorPalindromFor(digits) { | |
var n1 = Math.pow(10, digits) - 1; | |
for(var n2 = n1; n2 => 0; n2--) { | |
var value = n1 * n2; | |
if(isPalindrom(value)) { | |
console.log(`${n1} x ${n2} = ${value}`); | |
break; | |
} | |
} | |
} | |
function isPalindrom(num) { | |
var str = num.toString(); | |
return str == str.split('').reverse().join(''); | |
} | |
findMajorPalindromFor(3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment