Backwards and forwards

Take a whole number, for example 1746, and reverse it, obtaining for example 6471. Three non-obvious things:

  • The difference of the number and its reverse (or vice versa) is divisible by 9.
  • If the original number has an odd number of digits, the difference of the number and its reverse is divisible by 11 (and by 9, hence by 99).
  • If the original number has an even number of digits, the sum of the number and its reverse is divisible by 11.

Divisibility by 9

The number 1746 can be written as 1×103 + 7×102 + 4×10 + 6; in general an n–digit number can be written sum(i = 0..n-1) [di x 10i], where the di are the digits. Then the number minus its reverse, or vice versa if the reverse is larger, is |sum(i = 0..n-1) [di–d(n–i) x 10i]| = |sum(i = 0..n-1) [di x (10i–10(n–1–i))]|. For instance, 6471–1746 = (6–1)x103 + (4–7)x102 + (7–4)*10 + (1–6) = 6 x (103–1) + 4 x (102–10) + 7 x (10–102) + 1 x (1–103) = 6 x 999 + 4 x 90 – 7 x 90 – 1 x 999. That last number is obviously divisible by 9, and in the general case the result is divisible by 9 if (10i–10(n–1–i)) is. But 10m mod 9 = 1 for all m, so (10i–10(n–1–i)) mod 9 = 0.

Divisibility by 11

As before, the difference is divisible by 11 if (10i–10(n–1–i)) is, where in this case n is odd; let n = 2k+1; then (10i–10(n–1–i)) = (10i–10(2k–i)). But 10 mod 11 = 10 = –1 mod 11, therefore 10m mod 11 = 1 (10) if m is even (odd). i and (2ki) have the same parity, so 10i mod 11 = 10(2k–i) mod 11, and (10i–10(2k–i)) mod 11 = 0.

By similar reasoning, when n = 2k is even, the sum is divisible by 11 if (10i+10(2k–1–i)) is. i and 2k–1–i have opposite parity, so 10i mod 11 = –10(2k–1–i) mod 11, and (10i+10(2k–1–i)) mod 11 = 0.