1

Consider the 4th problem of the Project Euler:

A palindromic number reads the same both ways. The largest palindrome made from the product of two $2$-digit numbers is $9009$ = $91 \times 99$.

Find the largest palindrome made from the product of two $3$-digit numbers.

I found a solution but there are better solutions. The one given by the Project Euler community uses this fact:

Consider the digits of $P$ let them be $x$, $y$ and $z$. $P$ must be at least $6$ digits long since the palindrome $111111 = 143\times 777$ – the product of two $3$-digit integers.

My question is why is it not considering palindrome numbers with $5$ digits from $11111$ to $99999$ since they can be possibly obtained by the product of 2 3-digits numbers? I mean if it were not for the example given in the solution $111111 = 143\times 777$ we would not know if such a a palindrome exists, and if it is a 5 or 6 digits palindrome, would we?

1 Answers1

2

The question asks to find the largest palindrome number made from the product of two $3$ digit numbers .

If you know that $111111=143\times 777$ (which is a palindrome and the product of $2$ three digit numbers) then you also know that the numbers you are trying to find has $\ge 6$ digits because a number with less than $6$ digits cant be the largest palindrome because $111111>$any number with less than $6$ digits .

Vivaan Daga
  • 5,531
  • Yes, I thought I made clear in my question I had understood this fact. However, when you approach this problem you do not know that, and the approach of first finding such a couple of numbers loses a bit of generality in my opinion, especially when translating this into programming language code. – Francesco Boi Apr 17 '21 at 14:24
  • @FrancescoBoi You do not know what ? The problem asks to find the largest number nothing else . – Vivaan Daga Apr 17 '21 at 14:27
  • What I mean is the following. Suppose you approach the problem for the first time. From the problem statement you can assume that at least a pair of 3-digits numbers produces a palindrome. However, you do not know the palindrome will be 6 or 5 digits, there is no guarantee about that. So hardly you would approach such a problem by first looking that a least a pair of 3-digits numbers produces a 6-digits palindrome. The general approach is to find a solution that works in all cases. That is what I wanted to explain. – Francesco Boi Apr 22 '21 at 13:30
  • @FrancescoBoi, so I think that you want to know how to solve if you don't know that particular product. I agree that it is not easy to see that 111111 has 2 3-digits factors. – Sigur Jul 28 '22 at 02:06