Why is it that if a numbers is divisible by three, then the digits are also divisible by three?

Consider every integer xx can be written as

x=iZai10i x = \sum_{i \in Z} a_i 10^i

where ZZ is the set of all integers, and \(a_i \in {0, 1, …, 9}\) for all iZi \in Z. This can be rewritten as

x=iZai(10i1+1) x = \sum_{i \in Z} a_i (10^i-1+1)

It follows that if 10i110^i -1 is divisible by three for all iZ+i \in Z^+ then it follows that xx is divisible by three if the sum of the digits are also divisible by three since:

iZai(10i1+1)mod3=iZaimod3 \sum_{i \in Z} a_i (10^i-1+1) \mod 3 = \sum_{i \in Z} a_i \mod 3


Lets begin by proving that 10i110^i -1 is divisible by three for all iZi \in Z.

If i=0i = 0, then we know that 00 is clearly divisible by three. We can also easily verify this is true for i=1i = 1 since 101=910-1 = 9 is clearly divisible by three.

Now assuming that case i=ki=k holds, we need to demonstrate that case k+1k+1 also hold.

So assuming that

10k1mod3=0 10^k -1 \mod 3 = 0

then

10k+11mod3=(10k1+1)×101mod3 10^{k+1} - 1 \mod 3 = (10^{k} - 1 + 1) \times 10 - 1 \mod 3

Since we have assumed that 10k1mod3=0 10^k -1 \mod 3 = 0 , the expression above simplifies to:

101mod3=9mod3=0 10-1 \mod 3 = 9 \mod 3 = 0

as required.

Therefore since

x=iZai10i=iZai(10i1+1) x = \sum_{i \in Z} a_i 10^i = \sum_{i \in Z} a_i (10^i-1+1)

Then

x=iZai(10i1+1)mod3=iZaimod3 x = \sum_{i \in Z} a_i (10^i-1+1) \mod 3 = \sum_{i \in Z} a_i \mod 3

as required.