Library/Number Theory/Divisibility rules/Divisibility rules for 3 and 9

Divisibility rules for 3 and 9

Overview

Divisibility by 3

A number is divisible by 33 iff the sum of its digits is divisible by 33.

Divisibility by 9

A number is divisible by 99 iff the sum of its digits is divisible by 99.

[!IMPORTANT] A base-10 integer NN has the same remainder mod 33 and mod 99 as its digit sum.

Why the digit-sum rule works: 101(mod3)10 \equiv 1 \pmod{3} and (mod9)\pmod{9}

Write a positive integer in base 10:

N=d0+d110+d2102++dn10n.N = d_0 + d_1\cdot 10 + d_2\cdot 10^2 + \cdots + d_n\cdot 10^n.

Modulo 3: We have 101(mod3)10 \equiv 1 \pmod{3}, so 10k1(mod3)10^k \equiv 1 \pmod{3} for every k0k \ge 0. Therefore:

Nd0+d1+d2++dn(mod3).N \equiv d_0 + d_1 + d_2 + \cdots + d_n \pmod{3}.

So NN and the digit sum leave the same remainder when divided by 33. In particular:

  • 3N3 \mid N iff 3(digit sum)3 \mid (\text{digit sum}).

Modulo 9: Similarly 101(mod9)10 \equiv 1 \pmod{9}, so 10k1(mod9)10^k \equiv 1 \pmod{9}. Hence:

Nd0+d1++dn(mod9).N \equiv d_0 + d_1 + \cdots + d_n \pmod{9}.

So 9N9 \mid N iff 9(digit sum)9 \mid (\text{digit sum}).

Example

  • 47614\,761 has digit sum 4+7+6+1=184+7+6+1 = 18. So 4761180(mod9)4\,761 \equiv 18 \equiv 0 \pmod{9}, hence divisible by 99 (and by 33).