Academy
Maths›Number Theory›Divisibility›Divisibility Rules

Divisibility Rules

Divisibility rules are not tricks to memorise — they are theorems about what happens to a number's digits modulo small primes. Each rule has a one-line proof.

Why does the rule for 3 use the sum of digits, while the rule for 4 uses only the last two digits?

These are not arbitrary mnemonics. They are consequences of a single idea: the value of each digit depends on its position, and different moduli react differently to powers of 10.


The underlying idea

Every positive integer nn can be written in terms of its digits:

n=dk⋅10k+dk−1⋅10k−1+⋯+d1⋅10+d0n = d_k \cdot 10^k + d_{k-1} \cdot 10^{k-1} + \cdots + d_1 \cdot 10 + d_0

To check if m∣nm \mid n, reduce modulo mm:

n≡dk⋅(10k mod m)+⋯+d1⋅(10 mod m)+d0(modm)n \equiv d_k \cdot (10^k \bmod m) + \cdots + d_1 \cdot (10 \bmod m) + d_0 \pmod{m}

The rule for mm depends entirely on the pattern of 10k mod m10^k \bmod m.


Rule for 2 and 5

10≡0(mod2)10 \equiv 0 \pmod{2} and 10≡0(mod5)10 \equiv 0 \pmod{5}.

So 10k≡010^k \equiv 0 for all k≥1k \geq 1, meaning all digits except the last vanish:

n≡d0(mod2)andn≡d0(mod5)n \equiv d_0 \pmod{2} \quad \text{and} \quad n \equiv d_0 \pmod{5}

Rule. 2∣n  ⟺  2 \mid n \iff last digit is 0,2,4,6,0, 2, 4, 6, or 88.

Rule. 5∣n  ⟺  5 \mid n \iff last digit is 00 or 55.


Rule for 4 and 25

100≡0(mod4)100 \equiv 0 \pmod{4} and 100≡0(mod25)100 \equiv 0 \pmod{25}.

So 10k≡010^k \equiv 0 for all k≥2k \geq 2:

n≡d1⋅10+d0(mod4)andn≡d1⋅10+d0(mod25)n \equiv d_1 \cdot 10 + d_0 \pmod{4} \quad \text{and} \quad n \equiv d_1 \cdot 10 + d_0 \pmod{25}

Rule. 4∣n  ⟺  44 \mid n \iff 4 divides the last two digits.

Rule. 25∣n  ⟺  2525 \mid n \iff 25 divides the last two digits.

Example. 4∣18364 \mid 1836? Last two digits: 36=4×936 = 4 \times 9. Yes.

Rule for 8 and 125

1000≡0(mod8)1000 \equiv 0 \pmod{8} and 1000≡0(mod125)1000 \equiv 0 \pmod{125}.

Rule. 8∣n  ⟺  88 \mid n \iff 8 divides the last three digits.

Rule. 125∣n  ⟺  125125 \mid n \iff 125 divides the last three digits.


Rule for 3 and 9

10≡1(mod3)10 \equiv 1 \pmod{3} and 10≡1(mod9)10 \equiv 1 \pmod{9}.

So 10k≡1k=110^k \equiv 1^k = 1 for all kk:

n≡dk+dk−1+⋯+d1+d0(mod3)n \equiv d_k + d_{k-1} + \cdots + d_1 + d_0 \pmod{3}

Rule. 3∣n  ⟺  33 \mid n \iff 3 divides the sum of digits of nn.

Rule. 9∣n  ⟺  99 \mid n \iff 9 divides the sum of digits of nn.

Example. Is 3∣473823 \mid 47382? Sum of digits: 4+7+3+8+2=244+7+3+8+2 = 24, and 3∣243 \mid 24. Yes.

Why casting out nines works. Since any digit dd contributes d(mod9)d \pmod 9, and 9≡0(mod9)9 \equiv 0 \pmod 9, you can drop any 9s or digit groups summing to 9. The remainder is the same.


Rule for 11

10≡−1(mod11)10 \equiv -1 \pmod{11}, so 10k≡(−1)k(mod11)10^k \equiv (-1)^k \pmod{11}:

n≡d0−d1+d2−d3+⋯(mod11)n \equiv d_0 - d_1 + d_2 - d_3 + \cdots \pmod{11}

Rule. 11∣n  ⟺  1111 \mid n \iff 11 divides the alternating sum of digits (starting from the right with ++).

Example. Is 11∣8543711 \mid 85437?

Alternating sum: 7−3+4−5+8=117 - 3 + 4 - 5 + 8 = 11. Yes, 11∣8543711 \mid 85437.

Example. Is 11∣911 \mid 9 (i.e., 9)? Alternating sum is 9. 11∤911 \nmid 9. No.


Rule for 7

10≡3(mod7)10 \equiv 3 \pmod{7}. The powers of 3 mod 7 cycle with period 6:

30≡1,31≡3,32≡2,33≡6,34≡4,35≡5,36≡1 …3^0 \equiv 1,\quad 3^1 \equiv 3,\quad 3^2 \equiv 2,\quad 3^3 \equiv 6,\quad 3^4 \equiv 4,\quad 3^5 \equiv 5,\quad 3^6 \equiv 1\ \ldots

So 10k(mod7)10^k \pmod 7 cycles: 1,3,2,6,4,5,1,3,2,…1, 3, 2, 6, 4, 5, 1, 3, 2, \ldots

There is no clean digit-sum rule for 7. The standard approach:

Practical method. Double the last digit, subtract from the rest. Repeat until small.

7∣n  ⟺  7∣(number without last digit)−2×(last digit)7 \mid n \iff 7 \mid (\text{number without last digit}) - 2 \times (\text{last digit})

Why. If n=10q+d0n = 10q + d_0, then n−2d0=10q+d0−2d0=10q−d0n - 2d_0 = 10q + d_0 - 2d_0 = 10q - d_0. And 7∣10q−d0  ⟺  7∣10(10q−d0)=100q−10d0≡2q−3d07 \mid 10q - d_0 \iff 7 \mid 10(10q-d_0) = 100q - 10d_0 \equiv 2q - 3d_0... the cleaner proof: n≡0(mod7)  ⟺  10q+d0≡0  ⟺  3q+d0≡0  ⟺  q≡−d0⋅3−1≡−d0⋅5≡2d0(mod7)n \equiv 0 \pmod 7 \iff 10q + d_0 \equiv 0 \iff 3q + d_0 \equiv 0 \iff q \equiv -d_0 \cdot 3^{-1} \equiv -d_0 \cdot 5 \equiv 2d_0 \pmod 7... the doubling-and-subtracting shortcut collapses this.

Example. Is 7∣8747 \mid 874?

87−2(4)=87−8=7987 - 2(4) = 87 - 8 = 79.

7−2(9)=7−18=−117 - 2(9) = 7 - 18 = -11.

7∤−117 \nmid -11, so 7∤8747 \nmid 874.


Rule for 13

10≡10(mod13)10 \equiv 10 \pmod{13}, and powers of 10 mod 13 cycle with period 6:

1,10,9,12,3,4,1,10,…1, 10, 9, 12, 3, 4, 1, 10, \ldots

Practical method. Multiply the last digit by 4, add to the rest. Repeat.

13∣n  ⟺  13∣(number without last digit)+4×(last digit)13 \mid n \iff 13 \mid (\text{number without last digit}) + 4 \times (\text{last digit})


Summary table

DivisorKey congruenceRule
210≡010 \equiv 0Last digit even
310≡110 \equiv 1Sum of digits divisible by 3
4100≡0100 \equiv 0Last two digits divisible by 4
510≡010 \equiv 0Last digit is 0 or 5
710≡310 \equiv 3, period 6Double last digit, subtract
81000≡01000 \equiv 0Last three digits divisible by 8
910≡110 \equiv 1Sum of digits divisible by 9
1110≡−110 \equiv -1Alternating digit sum
1310≡1010 \equiv 10, period 6Multiply last digit by 4, add
25100≡0100 \equiv 0Last two digits divisible by 25

Worked problems

Problem 1. Find the smallest 5-digit number divisible by 9 with digit sum 18.

Digit sum 18 guarantees divisibility by 9. Smallest 5-digit: 1000810008 — digit sum 1+0+0+0+8=91+0+0+0+8 = 9. Not 18.

Try 1000810008's neighbors... actually minimize: put the largest digits at the end. 1000810008 has sum 9. We want sum 18. Minimum 5-digit with sum 18: 1008910089 (sum: 1+0+0+8+9=181+0+0+8+9=18). Check: 10089/9=112110089 / 9 = 1121. ✓

Problem 2. A 6-digit number 1a2b3c‾\overline{1a2b3c} is divisible by 11. Find the relationship between aa, bb, and cc.

Alternating sum (right to left): c−3+b−2+a−1=a+b+c−6c - 3 + b - 2 + a - 1 = a + b + c - 6.

For divisibility by 11: 11∣a+b+c−611 \mid a + b + c - 6, so a+b+c≡6(mod11)a + b + c \equiv 6 \pmod{11}.

Since a,b,c∈{0,…,9}a, b, c \in \{0,\ldots,9\}, the sum a+b+c∈{0,…,27}a+b+c \in \{0,\ldots,27\}, giving a+b+c∈{6,17}a+b+c \in \{6, 17\}.

Problem 3. Prove that 10n−110^n - 1 is always divisible by 9.

10≡1(mod9)10 \equiv 1 \pmod 9, so 10n≡1(mod9)10^n \equiv 1 \pmod 9, giving 10n−1≡0(mod9)10^n - 1 \equiv 0 \pmod 9. ■\blacksquare

This is why the digit-sum rule works: n−(digit sum)=n - (\text{digit sum}) = a multiple of 9 always.

Problem 4. Show that no perfect square ends in 2, 3, 7, or 8.

Squares mod 10: 02=0,12=1,22=4,32=9,42=6,52=5,62=6,72=9,82=4,92=10^2=0, 1^2=1, 2^2=4, 3^2=9, 4^2=6, 5^2=5, 6^2=6, 7^2=9, 8^2=4, 9^2=1.

Last digits of squares: {0,1,4,5,6,9}\{0,1,4,5,6,9\} only. The digits 2, 3, 7, 8 never appear. ■\blacksquare