This is the proof that this works for every multiple of 3:
Start with a number with digits, such as the 3 digit number 327. We'll call each of these digits , starting from for the first digit and ending with for the last digit. So 327 has , , and .
Our number is equal to the following:
This is just the hundreds, tens, units formulation of numbers. For example:
Now the trick is to replace each with . For example .
Now we'll make some terms switch places in the equation:
Notice that in the last line above we have eliminate the term because it's a multiplication by 0.
Now, if our original number is a multiple of 3, then it must be that the right hand side at the end of the above equation is a multiple of 3. Any string of 9s is always a multiple of 3 since . It is also a multiple of 9, but we'll get to that later. This means that the two bracketed terms in the last line of the above equation are both multiples of 3 because:
- : is a multiple of 3 by definition (we said that the number would be one).
- : is a sum of numbers multiplied by strings of 9s, which means that we can factor out the common factor 3.
The difference of two multiples of 3 is itself a multiple of 3. Therefore the left hand side must also be a multiple of 3 (since the two sides are equal), and the left hand side just happens to be:
which is the sum of all digits. Hence for any number that is a multiple of 3, the sum of its digits must also be a multiple of 3.
Until now we have only shown that any multiple of 3 will have the sum of its digits also be a multiple of 3. But can a number which is not a multiple of 3 coincidentally have the sum of its digits be a multiple of 3? No, because otherwise it would imply that a non-multiple of 3 minus a multiple of 3 is a multiple of 3. The second term in the subtraction in the right hand side of the above derivation is always going to be a multiple of 3, but in order for the whole of the right hand side to be a multiple of 3 you will need both terms being a multiple of 3. So you can rest your mind that checking if a large number is a multiple of 3 can be as simple as checking if the sum of its digits is a multiple of 3. And if that sum is still too big you can check if the sum of its digits are a multiple of 3 and so on, because you're always just reusing the same test each time.
What about multiples of 9? As already mentioned above, a string of 9s is also always a multiple of 9. So the second term in the subtraction above is also always a multiple of 9. Hence if both terms of the subtraction are multiples of 9, then the sum of digits is going to be a multiple of 9.