Two integers $$a, b \in \mathbb{N}$$ are mirror numbers if each number consists of the digits of the other number in reverse order. For example, 123 and 321 are mirror numbers.
Two mirror numbers $$a, b \in \mathbb{N}$$ are mirror factors of an integer $$p \in \mathbb{N}$$ if $$a \times b = p$$. For example, 165 and 561 are mirror factors of 92 565, because \[ 165 \times 561 = 92\,565 \]
Mirror factors are not necessarily unique. Some integers have no mirror factors at all. Others have multiple mirror factors. For example, 1 115 892 288 has three pairs of mirror factors: \[ \begin{array}{rcl}13\,248 \times 84\,231 = 1\,115\,892\,288 \\ 23\,184 \times 48\,132 = 1\,115\,892\,288 \\ 27\,504 \times 40\,572 = 1\,115\,892\,288 \end{array} \]
Two integers $$p, n \in \mathbb{N}_0$$, each on a separate line.
For each pair of mirror factors $$a, b \in \mathbb{N}$$ of $$p$$ for which $$a \leq b$$, output a line formatted as
a × b
The mirror factors of $$p$$ must be written out according to ascending first factor ($$a$$). If $$p$$ has more than $$n$$ mirror factors, only the first $$n$$ mirror factors must be written out.
To find the mirror factors of an integer $$p$$, you could check all possible integers that may qualify as mirror factors of $$p$$.
If two integers $$a, b \in \mathbb{N}_0$$ satisfy $$a \leq b$$ and $$a \times b = p$$, then $$a \leq \sqrt{p}$$ also holds. Use this property to limit the number of candidate mirror factors you must check.
The character × that you must use in the output (a × b) is a specific character that should not be confused with the lowercase letter x. It is recommended that you copy the character from the description of this assignment if you wish to include it in your program code.
Input:
1115892288
2
Output:
13248 × 84231
23184 × 48132
This solution to find the mirror factors of 92 565 is by V. Dubrovsky. The size of the product shows that the factors must have three digits each. So let one of them be $$xyz$$ (or $$100x + 10y + z$$) and the other be $$zyx$$. The product ends in 5, so either $$x$$ or $$z$$ must be 5. Say that's $$x$$. The other factor starts with 5, and $$\frac{92565}{500} < 200$$, so $$z$$ must be 1. As to $$y$$, we can see that the 6 in 92 565 is the last digit of $$5y + y$$, or $$6y$$, so $$y$$ must be either 1 or 6, and we can test these candidates to learn that it's 6. The numbers we seek are 165 and 561.
Robert Filman points out that we can solve this without actually having to multiply the numbers together. The sum of the digits of any number is the remainder of that number divided by 9, and the sum of the digits of $$92\,565\!\!\!\!\mod{9} = 0$$. So once we've established that the end digits of the factors we're seeking are 1 and 5 and that the middle digit is 1 or 6, as above, we can notice that none of the resulting candidates (115, 165, 511, 561) has a digit sum divisible by 9 and hence each factor must be divisible by 3 — which means that the digit sum of each factor must be a multiple of 3. The only possibilities are 165 and 561.