Motivation

My friends invited me to lunch at the Google office today (very fortunate for a man who’s fending on his own). While eating, we somehow ended up debating the supposed superiority of the dragon over the hare in the Chinese zodiac. As a loyal hare, I came to the defense of hares everywhere by claiming that 1999 is a far more interesting number than the boring 2000. For whatever reason, this led me to ask whether 1999 is divisible by 3. It felt like it should be. (Of course it isn’t—1999 is prime and the concatenation of three 9s, a number which is the square of another great prime. What a fantastic number!)

Two friends at the table immediately said no, and I was impressed by how quickly they answered. When I asked how they knew, they replied, “Didn’t you ever learn the trick where you sum the digits and check whether that sum is divisible by 3?” I hadn’t. To test it, I tried 201: 2+0+1=32+0+1=3, and indeed it’s divisible by 3. Same with 2001. The rule seemed to work, but when I asked whywarum muss das sein?—no one at the table had an answer.

We must roll up our sleeves so as to determine why is must be.

Proof

We will show that a number is divisible by 3 if and only if the sum of its digits is divisible by 3. We begin with the two-digit case and then generalize. (We ignore the one-digit case because it is trivial.)

Two-Digit Number

Let a two-digit number be written as d1d0d_1d_0 in base-10, meaning

10d1+d0.10d_1 + d_0.

Let

x=d1+d0,y=10d1+d0.x = d_1 + d_0, \qquad y = 10d_1 + d_0.

Assume that xx is divisible by 3, so x=3kx = 3k for some integer kk. Then we may rewrite

d0=xd1.d_0 = x - d_1.

Substituting into the expression for yy, we obtain

y=10d1+(xd1)=9d1+x.\begin{aligned} y &= 10d_1 + (x - d_1) \\ &= 9d_1 + x. \end{aligned}

Both terms on the right-hand side are divisible by 3: x=3kx = 3k by assumption, and 9d1=3(3d1)9d_1 = 3(3d_1). Therefore,

y=3(k+3d1),y = 3(k + 3d_1),

which shows that yy is divisible by 3.

Thus, for a two-digit number, divisibility by 3 is equivalent to the divisibility by 3 of the sum of its digits.

The General Case

Now consider an nn-digit number written as

dn1dn2d0,d_{n-1}d_{n-2}\ldots d_0,

which represents the integer

y=i=0n110idi.y = \sum_{i=0}^{n-1} 10^i d_i.

Let the sum of its digits be

x=i=0n1di.x = \sum_{i=0}^{n-1} d_i.

Assume that xx is divisible by 3, so x=3kx = 3k for some integer kk.

We separate the i=0i=0 term in the expression for yy:

y=d0+i=1n110idi.y = d_0 + \sum_{i=1}^{n-1} 10^i d_i.

From the definition of xx, we have

d0=xi=1n1di.d_0 = x - \sum_{i=1}^{n-1} d_i.

Substituting this into the expression for yy yields

y=xi=1n1di+i=1n110idi=x+i=1n1(10i1)di.\begin{aligned} y &= x - \sum_{i=1}^{n-1} d_i + \sum_{i=1}^{n-1} 10^i d_i \\ &= x + \sum_{i=1}^{n-1} (10^i - 1)d_i. \end{aligned}

For each i1i \ge 1, we may write

10i1=9(10i1+10i2++1),10^i - 1 = 9(10^{i-1} + 10^{i-2} + \cdots + 1),

which is a multiple of 9 and therefore a multiple of 3. Hence, each term (10i1)di(10^i - 1)d_i is divisible by 3, and so is their sum.

Since x=3kx = 3k is also divisible by 3, it follows that 3y3 \mid y, another notation to say “3 divides yy”. This completes the proof for the general case.

Conclusion

I am now rather satisfied with this answer, and it will be a technique I use to quickly check divisibility by 3. Naturally, I am now curious what other similar shortcuts exist, besides the obvious divisibility by 2 or 5 where we need only check the last digit.