Hacker News new | ask | show | jobs
by kazinator 1675 days ago
There is a nice, succinct explanation for this (which relies on some intuition or knowledge of modulo arithmetic and congruences).

First, a small defnition: let dsum(X) denote "sum of the digits of the decimal representation of whole number x".

In the modulo 9 congruence, 0 and 9 are equivalent symbols. 9 ≡ 0 (mod 9). Though distinct integers outside of the congruence they are indistinguishable elements of the congruence.

Observe that since 9 is congruent to 0, the number 10 is congruent to 1: 10 ≡ 1 (mod 9). Therefore, all powers of 10 are also congruent to 1: 1 ≡ 10 ≡ 100 ≡ 1000 ... (mod 9).

Next, note that these numbers x ∈ {1, 10, 100, 1000, ...} all have the property that x ≡ dsum(X) (mod 9). The sum of decimal digits of each power of 10 is 1, and each power of 10 is congruent to 1, modulo 9.

Within a congruence, whenever we multiply by any congruence element that is indistinguishable from 1, we get the same element. So all of these numbers 1, 10, 100, ... are identity elements in the modulo 9 congruence.

Identity means that, for instance 7 ≡ 70 ≡ 700 ≡ 7000 = 7000 ... (mod 9). If we multiply the congruence element 7 by any power of 10, the result is congruent to 7, modulo 9, because 10 is the identity element: no matter how many times we multiply an integer by 10, the resulting integer is the same modulo 9 congruence element. (Moreover, also note that dsum(7) = dsum(70) = dsum(700) ...).

Next, note that every decimal integer is formed by a sum combination of multiples of power of 10.

For instance, 1234 is equal to 1 x 1000 + 2 x 100 + 3 x 10 + 4.

But suppose we do this arithmetic in the modulo 9 congruence: it must necessarily be that:

1000 + 200 + 30 + 4 ≡ 1 + 2 + 3 + 4 (mod 9).

This is because, individually, 1000 ≡ 1 (mod 9), and 200 ≡ 2 (mod 9), 30 = 3 (mod 9). The power of 10 factors do not matter, since they are really powers of the identity element 1 in the mod 9 congruence.

The succinct explanation is then: every whole number has a decimal form made up of digits, which are multiplied by powers of 10. But in the modulo 9 congruence, powers of 10 do not matter: they map to the multiplicative identity element 1. That leaves the sum of the digits indistinguishable (in the modulo 9 congruence) from the value of the number (which is also a kind of sum of the digits, with each digit being scaled by a different power of 10).