# Find numbers $\overline{abcd}$ so that $\overline{abcd}+\overline{bcd}+\overline{cd}+d+1=\overline{dcba}$

Find the numbers $\overline{abcd}$, with digits not null that satisfy the equality

\begin{equation}\overline{abcd}+\overline{bcd}+\overline{cd}+d+1=\overline{dcba}\end{equation}

where \begin{equation}\overline{abcd}=1000a+100b+10c+d\end{equation}

I see that $4d+1=\overline{..a},\ d\neq0,\ a\neq 0,\ a<d$ but that gives too many pairs to start with $(d,a)\in\{(5,1),(6,5),(8,3),(9,7)\}$

• What does that notation mean? What sort of "numbers" are these? – lulu Jul 15 '15 at 13:41
• @lulu $\overline{abcd}$ means the number $10^3a+10^2b+10c+d$. – MJD Jul 15 '15 at 13:42
• @MJD Got it, thanks! – lulu Jul 15 '15 at 13:43
• I always used $[a,b,c,d] = 1000a + 100b + 10c + d$ One advantage is, you can write things like $[9,10,11,12] = [1,0,1,2,2]$. – steven gregory Jul 16 '15 at 23:04
• Are $a$, $b$, $c$, and $d$ non-zero decimal digits? – Joel Reyes Noche Jul 16 '15 at 23:16

\begin{array}{r} abcd\\ bcd\\ cd\\ d\\ 1\\ \hline dcba \end{array}

The leftmost $a$ in the top row cannot recieve more than $1$ as a carry. The worst cases are $(b,c)=(9,8)$ and $(b,c) = (8,9)$ as $(b,c) = (9,9)$ leads quickly to no solution. Hence $d = a + 1$ or $d = a$.

## Case: $d = a + 1$

Summing the rightmost column, we get \begin{align} 4d+1 &= a \pmod{10}\\ 4a+5 &= a \pmod{10}\\ 3a &= 5 \pmod{10}\\ a &= 5\\ d &= 6 \end{align}

Carrying the $2$ and summing the third column, we get $3c + 2 = 10k + b$ where $k \in \{0, 1, 2\}$.

Finally, from the second column, we get $2b + k = 10 + c$.

So $2b = 10 + c - k = 6c + 4 - 20k$
$5c = 19k + 6$

The only solution is $k = 1, c = 5$, and $b = 7$.

So $\overline{abcd} = 5756$

## Case: $d=a$.

Summing the rightmost column, we get \begin{align} 4d+1 &= a \pmod{10}\\ 4a+1 &= a \pmod{10}\\ 3a &= 9 \pmod{10}\\ a &= 3\\ d &= 3 \end{align}

Carrying the $1$ and summing the third column, we get $3c + 1 = 10k + b$ where $k \in \{0, 1, 2\}$.

Finally, from the second column, we get $2b + k = c$.

So $2b = c - k = 6c + 2 - 20k$
$5c = 19k - 2$

which has no solution.

As you observed, $$(d,a) \in \{(5,1), (8,3), (9,7), (6, 5)\}$$ but notice also that $d = a+k_3$, where $k_3$ is the carry resulting from $bcd+cd+d+1$. This quantity is at most $999+99+9+1 = 1108$ so the carry is either $0$ or $1$ and thus $d = a$ or $d=a+1$. Combined with the foregoing, this means that $(d,a) = (6, 5)$.

Now we have $$\overline{5bc6} + \overline{bc6} + \overline{c6} + 6 + 1 = \overline {6cb5}$$ and at this point anything we do will solve the problem as there are only 9 possibilities to check. Remembering we need $10\le 2b+k_2 \le 19$ where $k_2$ is the carry resulting from $\overline{c6} + 7$, so $b\ge 5$, we do trial and error on $b\in \{5,6,7,8,9\}$ and immediately find $b=5, c=7$.

Computer search confirms the uniqueness of the answer.

• Incidentally, $15512 + 5512 + 512 + 12 + 2 + 1 = 21551$ and $67967 + 7967 + 967 + 67 + 7 + 1 = 76976$. – MJD Jul 15 '15 at 14:19
• Isn't $k_3$ actually the carry resulting from $2bcd+cd+d+1$? After all, ignoring the middle mismatches, $7999+999+99+9+1=9107$ has a carry of $2$. – Barry Cipra Jul 15 '15 at 14:38
• You're absolutely right. Fortunately it doesn't otherwise change the discussion. Please feel free to edit the post if you like. – MJD Jul 15 '15 at 14:42

$$\begin{equation}\overline{abcd}+\overline{bcd}+\overline{cd}+d+1=\overline{dcba}\end{equation}$$

Expanding the numbers you get $$999a+190b-70c-996d+1=0$$

modulo $10$ you get $$-a+4d+1=0$$ which leads to the possibilities you listed.

Moreover $$999(a-d) =70c+3d-190b-1 \in (-1711, 657)$$ This yields $$a-d \in \{ -1, 0 \}$$

This reduces the pairs to $a=5, d=6$. Plugging in in the original equation we get $$999*5+190b-70c-996*6+1=0$$ $$190b-70c-980=0$$ $$19b-7c=98$$ As $7|98$ and $7|7c$ you have $7|19b$ and hence $7|b$.

This yields $b=0$ or $b=7$. $b=0$ is not possible, while $b=7$ yields $$19*7-7c=14*7 \Rightarrow 19-c=14$$

I'm late to the game here, but I find it interesting that no one used the mod 3 identity for digit sums in base 10, which lets you go from the inside digits out, instead of the outside in.

\begin{align} \overline{abcd} + \overline{bcd} + \overline{cd} + d + 1 &= \overline{dcba}&(\textrm{mod 3}) \\ (a + b + c + d) + (b + c + d) + (c + d) + d + 1 &= (a + b + c + d) &\quad(\textrm{mod 3}) \\ a + 2b + 3c + 4d + 1 &= a + b + c + d &(\textrm{mod 3}) \\ a + 2b + d + 1 + 3(c+d) &= a + b + c + d &(\textrm{mod 3}) \\ a + 2b + d + 1 &= a + b + c + d &(\textrm{mod 3}) \\ b + 1 &= c &(\textrm{mod 3}) \\ \end{align} Since $a \le d$, we know that the $4d+1$ in the ones place produces a carry of at least 1, so for some carry digits $k$ and $l$:

\begin{align} l &\in \{1, 2, 3\} \\ 3c + l &= \overline{kb} \\ b + 1 &= c &(\textrm{mod 3}) \\ 2b + k &= c &(\textrm{mod 10}) \end{align}

You can go through each of the 9 possible values of $c$, and for any given $c$, you only need to pick one of the three possible values of $l$ to uniquely determine $k$ and $b$. You can usually tell pretty quickly which $l$ value (if any) will give a $b$ with the right value mod 3, so this is only a little tedious by hand. This leads to only one solution, $(b, c, k, l) = (7, 5, 1, 2)$.

From this you know that $5 \le d \le 7$ (to get the carry digit $l=2$), and $d = a+1$ (because $2b+l=15$, carrying a 1). Since $a$ must be odd, $d$ must be even, so the answer is $5756$.