A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
This one was tough.
I ended up calculating every palindrome for every 3 digit number, saving it into a list, sorting the list and returning the largest number. I also had to look up a good palindrome detection algorithm.
Here is the psuedo code:
for every number between 100 and 999
for every number between 100 and 999
if the product is a palindrome add the number to the list
return the list
is a palindrome
This algorithm works by shaving off every digit of the existing number, adding it to a “reverse” variable, and then multiplying by 10 to transform the reverse variable over. If the numbers are equal return true.
This yields the correct answer!
Let me know in the comments below if you have a better algorithm.
