Created
April 26, 2022 19:03
-
-
Save MuddyBootsCode/d352e284885a76e837339c827e41aea5 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 largestPalindromeProduct(n) { | |
let palindromes = []; | |
let base = Number('9'.repeat(n)); | |
for(let i = 1; i <= base; i++){ | |
for(let j = 1; j <= base; j++){ | |
let product = i * j; | |
if (product === Number(String(product).split('').reverse().join(''))){ | |
palindromes.push(n) | |
} | |
} | |
} | |
return Math.max(...palindromes); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment