Monday, August 28, 2017

Proof that the sum of digits of any multiple of 3 (or 9) is itself a multiple of 3 (or 9)

Take any multiple of 3, such as 327. You can verify that it really is a multiple of 3 by adding together all its digits, that is 3+2+7=12, and checking if the sum is itself a multiple of 3. 12 is a multiple of 3, so 327 must also be a multiple of 3. Since the sum of digits will be a much smaller number than the original number, it will be easier to determine if it is a multiple of 3 or not. Of course you can then take the sum of digits and find its sum of digits again repeatedly until it's a single digit number: 3, 6, 9. The same thing is true of multiples of 9 but instead the sum of digits will be a multiple of 9.

This is the proof that this works for every multiple of 3:

Start with a number with n digits, such as the 3 digit number 327. We'll call each of these digits ai, starting from an1 for the first digit and ending with a0 for the last digit. So 327 has a2=3, a1=2, and a0=7.

Our number is equal to the following:
an110n1+an210n2++a1101+a0100
This is just the hundreds, tens, units formulation of numbers. For example:
327=3×102+2×101+7×100=3×100+2×10+7×1=327

Now the trick is to replace each 10x with 999...+1. For example 100=99+1.

an110n1+an210n2++a1101+a0100=an1(999...+1)+an2(99...+1)++a1(9+1)+a0(0+1)=(an1999...+an1)+(an299...+an2)++(a19+a1)+(a00+a0)=(an1999...+an299...++a19+a00)+(an1+an2++a1+a0)

Now we'll make some terms switch places in the equation:
an1+an2++a1+a0=(an110n1+an210n2++a1101+a0100)(an1999...+an299...++a19+a00)=(an110n1+an210n2++a1101+a0100)(an1999...+an299...++a19)

Notice that in the last line above we have eliminate the term a00 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 999=3×3×111. 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:
  • an110n1+an210n2++a1101+a0100: is a multiple of 3 by definition (we said that the number would be one).
  • an1999...+an299...++a19: 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:

an1+an2++a1+a0

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.