Let $P(n)$ be the product of the digits of the number $n$, with $n \in \mathbb{N}$.
What is the product of all the natural numbers $n$ that verify the equation $P(n) = n^2 - 42n + 440$?
I factorized the polynomial to get $P(n) = (n - 20)(n - 22)$. Then I observed that $n = 20$ is a solution because $P(20) = 0$.
But at this point I got stuck, so I wrote an Haskell program that would calculate the solutions for me. After letting it run for a while I checked the output, which was: $[18, 20, 24]$. So apparently the answer is $18 \cdot 20 \cdot 24 = 8640$.
What is the correct, mathematical way to solve this?
Elaborating on the comments given by fixedp:
The number of digits in $n\in\mathbb N$ equals $\lfloor\log n\rfloor+1$. This is true since $n=10^{\log n}$ so the greatest power of $10$ that is less than or equal to $n$ is $10^{\lfloor\log n\rfloor}$ which has $\lfloor\log n\rfloor+1$ digits, and so does $n$. Since each digit of $n$ is at most $9$, it follows that $$ P(n)\leq 9^{\lfloor\log n\rfloor+1}<10^{\log n+1}=10n $$ since this bound is a linear expression in $n$ and $(n-20)(n-22)$ is a quadratic expression we see that $P(n)<10n<(n-20)(n-22)$ for $n$ large enough. Solving the equality $10x=(x-20)(x-22)$ yields $x\approx10.64$ or $x\approx41.36$ so the only range to check is $n\in\{11,12,...,41\}$. In particular only two-digit numbers apply!
Assuming $n=10a+b$ we must solve $ab=(10a+b-20)(10a+b-22)$ which is an elliptic curve with the following integer solutions: Link to Wolfram Alpha Computation.
This shows positively and definitively that the numers $18,20,24$ are in fact the only solutions.
Actually we can reduce the number of numbers to check once again, since we now know that $n\leq 41$ so $P(n)\leq P(39)=3\cdot 9=27$. Solving $27=(x-20)(x-22)$ yields $x\approx 15.71$ or $x\approx 26.29$. So now we only need to check the the range $n\in\{16,17,...,26\}$. It could hardly be easier now ...
If you cannot stop yourself, you can apply the same method to have $P(n)\leq P(26)=2\cdot 6=12$ and solve $12=(x-20)(x-22)$ to get $x\approx 17.39$ or $x\approx 24.6$ and therefore $n\in\{18,19,...,24\}$. Voila!