This is a consequence of the behavior of modular arithmetic, plus the fact that 10 = 1 (mod 9).
Your multiple of 9, as any other number, can be expressed as its digits multiplied by powers of 10; say, 1845 is 1.10^3 + 8.10^2 + 4.10 + 5. Now, being a multiple of 9 means that its remainder when divided by 9 is exactly zero. So you would write, 1845 = 0 (mod 9).
Arithmetic modulo some number n (in our case, modulo 9) has this useful properties:
If a = a' (mod n) and b = b' (mod n), the following are true:
- a^i = a'^i (mod n), for any integer i
So any expression you can write using sums, products or powers to some integer, will produce the same result whether
- you calculate the whole expression first, and then finally take the remainder modulo n, or
- you take the remainders modulo n of your numbers, and do the operation on the remainders, taking the modulo n after each operation.
For the example number above, you can do all operations "mod 9", taking notice that 10 = 1 (mod 9). Then you have:
1845
= 1.10^3 + 8.10^2 + 4.10 + 5
= 1.1^3 + 8.1^2 + 4.1 + 5
= 1 + 8 + 4 + 5 (mod 9)