A four-digit code leaves three traces: a sum, a multiple, and what happens when you read it backwards. Three conditions for a single number.

The code with checksum and reverse

Riddle statement

A code has four different figures.

It is known that:

  • is a multiple of 9;
  • the last figure is the remainder by dividing the sum of the first three by 10;
  • By reversing the order of its figures, the number obtained exceeds the original by 369 units.

What is the code?

Show solution

Solution

Answer:

$3924.$

Let the code be $abcd$. The number obtained by inverting its figures is $dcba$.

As this reverse exceeds the original by 369 units:

$dcba - abcd = 369.$

Es say:

$(1000d + 100c + 10b + a) - (1000a + 100b + 10c + d) = 369.$

Grouping:

$999(d - a) + 90(c - b) = 369.$

Dividing by 9:

$111(d - a) + 10(c - b) = 41.$

As $a, b, c, d$ are figures, the differences $d - a$ and $c - b$ are between $-9$ and $9$. The only integer combination that satisfies the equation is:

$d - a = 1, \qquad c - b = -7,$

so that:

$d = a + 1, \qquad c = b - 7.$

Now we use the condition of the last figure:

$d \equiv a + b + c \pmod{10}.$

Substitution $d = a + 1$ and $c = b - 7$:

$a + 1 \equiv a + b + (b - 7) \pmod{10},$

then:

$1 \equiv 2b - 7 \pmod{10},$

so that:

$2b \equiv 8 \pmod{10}.$

So $b$ must be congruent with 4 modulo 5. Since $c = b - 7$ must be a valid figure, $b$ can only be 7, 8 or 9. Of those three values, the only one congruent with 4 modulo 5 is $b = 9$, which gives $c = 2$.

Finally, the code is a multiple of 9, so the sum of its figures must be:

$a + 9 + 2 + (a + 1) = 2a + 12.$

The only figure $a$ that makes this sum a multiple of 9 is $a = 3$, so $2(3) + 12 = 18$. Then $d = 4$.

The code is $\mathbf{3924}$.

Check: the four figures are different; $3 + 9 + 2 + 4 = 18$, multiple of 9; $3 + 9 + 2 = 14$, whose remainder when divided by 10 is 4; the reverse is 4293, and $4293 - 3924 = 369$.