Is there a general solution for an equation such as N - M = 2021 where N is four digits and M is three digits of N

51 Views Asked by At

The question is, given N of four digts and M which is based on any three digits of N (but in the same order as those of N) and the difference between N and M is 2021, what is the original number N?

The way I have worked this out is to take all four digits of 2021 and add all four (2+0+2+1) =5 to give me the last digit of N so N = ???5. Then I take the first three digits of 2021 and add them (2+0+2) = 4 to give me the third digit of N so N = ??45. Next I take the first two digits of 2021 and add then (2+0) = 2 to give me the second digits of N so N = ?245 and finally I take the first digit of 2021 and 'add' it (2) = 2 and use that as the first digit of N so N = 2245. If I then 'lose' the last digit of N (e.g. the '5) I have M of 224.

This works because 2245 - 224 = 2021

But why? Is there a general solution for this? What am I missing?

1

There are 1 best solutions below

0
On

Note that if $M=abcd$ then $N=abc$ or $N=bcd$.

But since $abcd-bcd=a000\neq 2021$ only $N=abc$ can fit.

So you are left with $\quad abcd=2021+abc$

Which can be expressed as $\begin{cases} d=c+1&\bmod{10}\\ c=b+2+r_1&\bmod{10}\\ b=a+0+r_2&\bmod{10}\\ a=2+r_3&\bmod{10} \end{cases}$

where $r_1,r_2,r_3$ are the carry at each step of the addition (can be $0$ or $1$).

Notice that $a=2+r_3\le 3\implies a+0+r_2\le 4<10\implies r_3=0\ $ therefore $a=2$.

Similarly $b\le 3\implies b+2+r_1\le 6<10\implies r_2=0\ $ therefore $b=2$.

And so on $c\le 5\implies d\le 6<10\implies r_1=0\ $ therefore $c=4$ and $d=5$.

We have proved that the solution is unique: $$2245=2021+224$$