# The largest product of two n-digit numbers which is palindrome

Project Euler: 4 is stated as follows:

## Largest palindrome product

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.

Now I have solved this problem in several ways using programming. One ordinary solution was simply to generate all the products of two 3-digits numbers and pick the largest one. Now this problem can be optimized much further than that, however that is not the point of this question. If one wants to look at a programming solution to this problem, you can find my attempt here.

The first 10 solutions can be found below

 1:       None x       None =                 None
2:         99 x         91 =                 9009
3:        913 x        993 =               906609
4:       9999 x       9901 =             99000099
5:      99979 x      99681 =           9966006699
6:     999999 x     999001 =         999000000999
7:    9997647 x    9998017 =       99956644665999
8:   99999999 x   99990001 =     9999000000009999
9:  999920317 x  999980347 =   999900665566009999
10: 9999999999 x 9999900001 = 99999000000000099999


There is no single digit $a*b$ which can equal a palindrome, since all palindromes are divisible by $11$ and $a,b<10$ since $a$ and $b$ are single digit numbers.

From here a clear pattern emerges. If $n$ is even then the solution is

Solution of the largest palindrome product formed from two even-digit numbers. $$(\underbrace{9 \ldots 9}_{n \text{ times}}) \times (\underbrace{9 \ldots 9}_{n/2 \text{ times}} \ldots \underbrace{0 \ldots 0}_{n/2 - 1 \text{ times}} \ldots 1) = (\underbrace{9 \ldots 9}_{n/2 \text{ times}} \ldots \underbrace{0 \ldots 0}_{n \text{ times}} \ldots (\underbrace{9 \ldots 9}_{n/2 > \text{ times}})$$

Which in a pythonic sense can be written as

nine = '9'*(num/2)
num1 = nine + nine
num2 = nine + '0'*(-1 + num/2) + '1'
product = nine + '0'*(num) + nine
return ((int(num1), int(num2)), int(product))


My question is if a similar pattern can be found for the largest palindrome product formed from two odd digit-numbers.

I know a similar question has been asked before. However my question has still not been answered. The previous question was badly formated and contained factual errors. Eg the largest palindromic product formed from two 7-digit numbers is 99956644665999 not 94677111177649.

• Not all palindromes are divisible by $11$, like $101$ and $131$. – Julián Aguirre May 24 '16 at 14:00
• $3\times3=9$ is the largest palindromic product of a pair of one-digit numbers. – Barry Cipra May 24 '16 at 14:01
• @JuliánAguirre, I think the OP is assuming that the largest palindromic product will have $2n$ digits, in which case it will be divisible by $11$. (My other comment says that the assumption is not warranted when $n=1$.) – Barry Cipra May 24 '16 at 14:03

10 9999996699             9999986701                         99999834000043899999