10
$\begingroup$

If you multiply $2178$ by $4$ you will get the same digits, but written in the back order, like if you look in a mirror: $2178 \cdot 4 = 8712$.

How to find all possible natural numbers, that are mirrored when multiplied by 4? And prove that these are all numbers.

What other factors $F \neq 4$ have mirrored numbers?
I see that $F = 1$ has a trivial mirror number $1$, but I would like to have help with other $F=2,..,9$.

$\endgroup$
22
$\begingroup$

The factors are 1, 4 and 9

We consider a number a factor iff there exist a non zero integer which it mirrors.

$F = 1$ is clearly a factor for all palindromes (numbers that are already mirrors of themselves). The remaining factors must be in $[2,9]$ because:

  • negative $F$ produce numbers with opposite sign
  • $F = 0$ is factor only for the number $0$
  • $F \geq 10$ implies that the mirrored would have more digits than the original (we will stick to classical decimal notation: $F = 10$ is not a factor for $1 = 01$ and $9.999\ldots$ is not a valid notation for 10).

Let $\overline{a_n\ a_{n-1}\ \ldots a_0}$ be the decimal notation of a mirror $\sum\limits_{0 \leq i \leq n} a_i 10^{i}$ (mirrored in $\overline{a_0\ a_1\ \ldots a_n}$) for the factor $F$. Note that we will always use this notation with $n \geq 1$ and $a_n \neq 0$, it applies for all non-zero mirrors with $F > 1$ because they have a least two digits.

We have $a_0 \times F \equiv a_n$ mod $10$, $a_n \times F \leq a_0$ and $a_n \times F < 10$ therefore a simple brute force like this

for$a_0$, $a_n$, $F$ in $[1,9]^2 \times [2,9]$: if $a_0 \times F \equiv a_n$ mod $10$, $a_n \times F \leq a_0$ and $a_n \times F < 10$: print$a_0$, $a_n$, $F$

yields that the only possibilities with $F \in [2,9]$ are :

$$\begin{array}{|c|c|c|c|c|} \hline F & 2 & 3 & 4 & 9\\\hline a_0 & 6 & 7 & 8 & 9\\\hline a_n & 2 & 1 & 2 & 1\\\hline \end{array}$$

We can eliminate $F = 2$ instantly because $\overline{2\ a_{n-1}\ \ldots 6} \times 2 = \overline{6\ a_{1}\ \ldots 2}$ implies that $(2 \times 10^n + \overline{a_{n-1}\ \ldots 6}) \times 2 \geq 6 \times 10^n$ hence that $\overline{a_{n-1}\ a_{n-2}\ \ldots 6} \geq (\frac{6}{2} - 2) 10^n \geq 10^n$ yet we know that $\overline{a_{n-1}\ a_{n-2}\ \ldots 6} < 10^n$.

The same argument can be used for $F = 3$ : $\overline{1\ a_{n-1}\ \ldots 7} \times 3 = \overline{7\ a_{1}\ \ldots 3}$ therefore $\overline{a_{n-1}\ a_{n-2}\ \ldots 7} \times 3 \geq (7 - 1 \times 3) 10^n$ which is impossible.

So the possible factors are included in $\{1,4,9\}$.

All these factors have mirrors (for instance $4224$, $2178$ and $1089$ for respectively $1$, $4$ and $9$) so they are the only possible factors.

The mirrors are expressible with a context-free grammar

Using the same constraints as before we can numerically compute the possible extremities ($a_0$ and $a_n$) of the admissible numbers, then we have a slightly altered problem for the number without its extremities: in $2178 \times 4= 8712$ it corresponds to $17 \times 4 + 3 = 71$ (this $+3$ comes from $2008 \times 4 - 8002 = 3 . 10^1$).

We can show that a slightly more general class of mirror problems (with small offsets like this $+3$) can be solved using only very basic operators and other problems of the same class. This will allow us to express the mirrors numbers using context free grammar.

In the following $S_F(u,v)$ will be used to denote the solution of a mirror problem for factor $F$ with left offset $u$ and right offset $v$, more formally:

Given $F \in \{1,4,9\}$ and $u, v \in [0,9]^2$, let $S_F(u,v)$ be the set of numbers such that $\overline{a_n\ a_{n-1}\ \ldots a_0} \in S_F(u,v)$ iff $\overline{a_n\ a_{n-1}\ \ldots a_0} \times F + v - u 10^{n+1} = \overline{a_0\ a_1\ \ldots a_n}$

We are interested in $S_4(0,0) = \{\overline{a_n\ a_{n-1}\ \ldots a_0}\ |\ \overline{a_n\ a_{n-1}\ \ldots a_0} \times 4 = \overline{a_0\ a_1\ \ldots a_n} \}$ and $S_9(0,0)$

We have seen that the decimal notation of elements of $S_4(0,0)$ starts with 2 and ends 8, lets have a look at what is between:

$\begin{align} \overline{a_{n}\ \ldots a_0} \in S_4(0,0) &\Leftrightarrow \overline{2\ a_{n-1}\ \ldots a_1, 8} \times 4 = \overline{8\ a_{1}\ \ldots a_n, 2}, a_0 = 8, a_n = 2\\ &\Leftrightarrow \overline{a_{n-1}\ \ldots a_1, 0} \times 4 + 32 = \overline{a_{1}\ \ldots a_n, 2}, a_0 = 8, a_n = 2\\ &\Leftrightarrow \overline{a_{n-1}\ \ldots a_1} \times 4 + 3 = \overline{a_{1}\ \ldots a_n}, a_0 = 8, a_n = 2\\ \overline{a_{n}\ \ldots a_0} \in S_4(0,0) &\Leftrightarrow \overline{a_{n-1}\ \ldots a_1} \in S_4(0,3), a_0 = 8, a_n = 2 \end{align}$

This can be expressed as $S_4(0,0) = 2.S_4(0,3).8$ (plus potential mirors with less than 2 digits as we only considered element of $S_4(0,0)$ of the form $\overline{a_{n}\ \ldots a_0}_{n \geq 1}$) where $.$ is the concatenation of digits. The mirrors with less than two digits can only be $0$ (1 digit numbers don't work), so $S_4(0,0) = 0 + 2.S_4(0,3).8$. where $+$ is the set union and $0$ stand for the singleton containing $0$, i.e. $\{0\}$.

Similarly $S_9(0,0) = 0 + 1.S_9(0,8).9$ because we know that $a_0 = 9, a_n = 1$ is the only possibility and $v = (a_0 \times F - a_n) /10 = (9 \times 9 - 1)/10 = 8$ and $u = a_0 - a_n \times F = 9 - 1 \times 9 = 0$.

More generally any $S_F(u,v)$ can be expressed using digit concatenation, digits, union and $\{S_F(i,j) | i,j \in [0,9]^2\}$

Explicitly the mirrors are:

$\begin{align*} S_1(0,0) &= 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 \\ &\ \ + 1.S_1'(0,0).1 + 2.S_1'(0,0).2 + 3.S_1'(0,0).3 + 4.S_1'(0,0).4 + 5.S_1'(0,0).5 + 6.S_1'(0,0).6 + 7.S_1'(0,0).7 + 8.S_1'(0,0).8 + 9.S_1'(0,0).9\\ &S_1'(0,0) = S_1(0,0) + \epsilon + 0.S_1'(0,0).0\\ S_4(0,0) &= 0 + 2.S_4(0,3).8\\ &S_4(0,3) = 17 + 1.S(3,3).7\\ &S_4(3,3) = 9 + 99 + 7.S(3,0).1 + 9.S_4(3,3).9\\ &S_4(3,0) = 82 + 8.S_4'(0,0).2\\ &S_4'(0,0) = S_4(0,0) + 00 + 0.S_4'(0,0).0\\ S_9(0,0) &= 0 + 1.S_9(0, 8). 9\\ &S_9(0, 8) = 08 + 0.S_9(8, 8).8\\ & S_9(8, 8) = 9 + 99 + 8.S_9(8, 0).0 + 9.S_9(8, 8).9\\ &S_9(8, 0) = 91 + 9.S_9'(0, 0).1\\ &S_9'(0, 0) = S_9(0, 0) + 00 + 0.S_9'(0, 0).0 \end{align*}$

Where

  • $.$ is the digit concatenation over sets: $a.b = \{\overline{u\ v} | u \in a, v \in b\}$
  • $\epsilon$ is its neutral, i.e. $\epsilon.a = a.\epsilon = a$
  • $+$ is the set union
  • numbers stands for singleton containing only themselves

We consider the minimal sets, for inclusion, satisfying the relations. The primed set are an artifact to avoid numbers starting with zeros.

Some quick and dirty python code to get this result.

Some examples

Let's construct some examples from the above description, we'll use some colors and parenthesis to highlight the construction. We will stick with $F = 4:$ and the following color code:

$$\begin{array}{|c|c|c|c|c|} \hline S_4(0,0) & S_4(0,3) & S_4(3,3) & S_4(3,0) & S_4'(0,0)\\\hline \color{blue}{0}, & \color{Orange}{17}, & \color{Green}{9}, \color{Green}{7}.S_4(3,0).\color{Green}{1}, & \color{Purple}{82}, & S_4(0,0), \color{Red}{00}\\ \color{blue}{2}.S_4(0,3).\color{blue}{8} & \color{Orange}{1}.S_4(3,3).\color{Orange}{7} & \color{Green}{99}, \color{Green}{9}.S_4(3,3).\color{Green}{9} & \color{Purple}{8}.S_4'(0,0).\color{Purple}{2} & \color{Red}{0}.S_4'(0,0).\color{Red}{0}\\\hline \end{array}$$

This table says that to get an element from a set you have to take elements from its column. Let's say we want an element of $S_4(0,0)$ (it's the ones we are interested in: the mirrors for $F = 4$ without offsets) : so you can take $\color{blue}{0}$ for instance, and indeed $0 \times 4 = 0$.

The only other possibility would be $\color{blue}{2}.S_4(0,3).\color{blue}{8}$, that means take an element of $S_4(0,3)$ put a $\color{blue}{2}$ before and a $\color{blue}{8}$ after and you are good. For instance $\color{Orange}{17}$ is an element of $S_4(0,3)$ therefore $\color{blue}{2}\color{Orange}{17}\color{blue}{8}$ is an element of $S_4(0,0)$, and indeed $2178 \times 4 = 8712$. In the following I'm gonna add parenthesis -like $\color{blue}{2}(\color{Orange}{17})\color{blue}{8}$ - to make the construction clearer.

We had to take an element from $S_4(0,3)$ and we took $\color{Orange}{17}$, we could also have chosen to use $\color{Orange}{1}.S_4(3,3).\color{Orange}{7}$, for instance $\color{Orange}{1}(\color{Green}{9})\color{Orange}{7}$ which leads to $\color{blue}{2}(\color{Orange}{1}(\color{Green}{9})\color{Orange}{7})\color{blue}{8}$ (and yes $21978 \times 4 = 87912$).

Some others examples are: $$\begin{array}{c|c|c} \color{blue}{2}(\color{Orange}{1}(\color{Green}{99})\color{Orange}{7})\color{blue}{8} & \color{blue}{2}(\color{Orange}{1}(\color{Green}{7}(\color{Purple}{82})\color{Green}{1})\color{Orange}{7})\color{blue}{8} & \color{blue}{2}(\color{Orange}{1}(\color{Green}{9}(\color{Green}{7}(\color{Purple}{82})\color{Green}{1})\color{Green}{9})\color{Orange}{7})\color{blue}{8} \\\hline \color{blue}{2}(\color{Orange}{1}(\color{Green}{9}(\color{Green}{99})\color{Green}{9})\color{Orange}{7})\color{blue}{8} & \color{blue}{2}(\color{Orange}{1}(\color{Green}{9}(\color{Green}{9}(\color{Green}{7}(\color{Purple}{82})\color{Green}{1})\color{Green}{9})\color{Green}{9})\color{Orange}{7})\color{blue}{8} & \color{blue}{2}(\color{Orange}{1}(\color{Green}{7}(\color{Purple}{8}(\color{Red}{00})\color{Purple}{2})\color{Green}{1})\color{Orange}{7})\color{blue}{8} \\\hline \color{blue}{2}(\color{Orange}{1}(\color{Green}{7}(\color{Purple}{8}(\color{blue}{0})\color{Purple}{2})\color{Green}{1})\color{Orange}{7})\color{blue}{8} & \color{blue}{2}(\color{Orange}{1}(\color{Green}{7}(\color{Purple}{8}(\color{blue}{2}(\color{Orange}{17})\color{blue}{8})\color{Purple}{2})\color{Green}{1})\color{Orange}{7})\color{blue}{8} & \color{blue}{2}(\color{Orange}{1}(\color{Green}{7}(\color{Purple}{8}(\color{red}{0}(\color{blue}{2}(\color{Orange}{17})\color{blue}{8})\color{red}{0})\color{Purple}{2})\color{Green}{1})\color{Orange}{7})\color{blue}{8} \end{array}$$

$$\begin{array}{c} \color{blue}{2}(\color{Orange}{1}(\color{Green}{7}(\color{Purple}{8}(\color{red}{0}(\color{blue}{0})\color{red}{0})\color{Purple}{2})\color{Green}{1})\color{Orange}{7})\color{blue}{8} \\\hline \color{blue}{2}(\color{Orange}{1}(\color{Green}{7}(\color{Purple}{8}(\color{red}{0}(\color{red}{0}(\color{red}{00})\color{red}{0})\color{red}{0})\color{Purple}{2})\color{Green}{1})\color{Orange}{7})\color{blue}{8} \\\hline \color{blue}{2}(\color{Orange}{1}(\color{Green}{7}(\color{Purple}{8}(\color{red}{0}(\color{red}{0}(\color{red}{0}(\color{blue}{2}(\color{Orange}{1}(\color{Green}{7}(\color{Purple}{8}(\color{blue}{0})\color{Purple}{2})\color{Green}{1})\color{Orange}{7})\color{blue}{8})\color{red}{0})\color{red}{0})\color{red}{0})\color{Purple}{2})\color{Green}{1})\color{Orange}{7})\color{blue}{8} \\\hline \color{blue}{2}(\color{Orange}{1}(\color{Green}{7}(\color{Purple}{8}(\color{blue}{2}(\color{Orange}{1}(\color{Green}{7}(\color{Purple}{8}(\color{blue}{2}(\color{Orange}{1}(\color{Green}{7}(\color{Purple}{8}(\color{red}{0}(\color{red}{0}(\color{blue}{2}(\color{Orange}{1}(\color{Green}{7}(\color{Purple}{8}(\color{blue}{0})\color{Purple}{2})\color{Green}{1})\color{Orange}{7})\color{blue}{8})\color{red}{0})\color{red}{0})\color{Purple}{2})\color{Green}{1})\color{Orange}{7})\color{blue}{8})\color{Purple}{2})\color{Green}{1})\color{Orange}{7})\color{blue}{8})\color{Purple}{2})\color{Green}{1})\color{Orange}{7})\color{blue}{8} \end{array}$$

$\endgroup$
  • $\begingroup$ +1 for considering "$9.999\ldots$ is not a valid notation for $10$". The result is impressive, but I guess for $F=1$ the only mirrored numbers are the single digits? $\endgroup$ – justhalf Aug 14 '14 at 5:37
  • 3
    $\begingroup$ @justhalf, for F=1 all palindrome numbers are mirrored. $\endgroup$ – klm123 Aug 14 '14 at 6:51
  • $\begingroup$ Sorry for that: indeed only numbers that are mirror of themselves are correct for $F=1$. $\endgroup$ – Ara Aug 14 '14 at 7:24
  • $\begingroup$ @klm123: If you feel like something is missing from my answer don't hesitate to ask: I'll try and make it better. $\endgroup$ – Ara Aug 24 '14 at 9:39
  • $\begingroup$ @Ara, may be examples? To make it more understandable. $\endgroup$ – klm123 Aug 24 '14 at 10:05
3
$\begingroup$

The numbers are:

$2178, 21978, 219978, ...$

$ 21782178, 217821782178, 2178217821782178, ... $ with $F = 4$

and

$1089, 10989, 109989, ... $

$10891089, 108910891089, ... $ with $ F = 9 $

$F \in [2,9]$

Why I will have to check in more detail but AFAIK there are the only two series.

$\endgroup$
  • $\begingroup$ Can you prove that these are all possible numbers for F=4? $\endgroup$ – klm123 Aug 10 '14 at 14:31
  • $\begingroup$ @klm123 I will see if I can come up with a proof. $\endgroup$ – ThreeFx Aug 10 '14 at 14:32
  • $\begingroup$ Solving this in mathematica gives the same results as shown here i.e. solution only possible for f=4 and 9. Also only one n digit mirror number is found for every n>=4 $\endgroup$ – Hubble07 Aug 10 '14 at 18:17
  • $\begingroup$ As shown in Riddle's computational answer, there are a few answers not quite in these patterns but formed by doubling them up: 21782178×4=87128712; 10891089×9=98019801. $\endgroup$ – IanF1 Aug 11 '14 at 21:02
2
$\begingroup$

I made a program for it, and its algorithm is to get an interval of numbers from the user, reverse and multiply every number in between, and if the reverse and multiplication is equal, then print it for you.

Here is a C# code:

Console.WriteLine("number from");
int a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("to");
int b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Multiplied by?");
int y = Convert.ToInt32(Console.ReadLine());
for (int i = a; i < b; i++)
{
    string reverse = new string(i.ToString().Reverse().ToArray());
    if (y * i == Convert.ToInt32(reverse))
        Console.WriteLine(i+"\t\t"+reverse+"\t\t"+"Mirror number");
}
Console.WriteLine("Processing finished");
Console.ReadLine();

My test for numbers between 10 to 30000000:

Console output

The process is not finished until "Processing finished" shows up.

$\endgroup$

protected by Community Jul 16 '17 at 19:34

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.