In school you memorised a collection of divisibility rules that felt like magic spells:

These are not disconnected tricks. They are all consequences of one fact in modular arithmetic: each rule reflects what powers of 10 look like modulo the divisor in question. Once you see this, you stop memorising individual rules and start deriving the right rule for any divisor on demand.

The one fact that generates everything

Every positive integer, when written in decimal, is a sum:

N = a_k \cdot 10^k + a_{k-1} \cdot 10^{k-1} + \cdots + a_1 \cdot 10 + a_0,

where a_i are the decimal digits. Modding by any m turns this into

N \equiv a_k \cdot 10^k + a_{k-1} \cdot 10^{k-1} + \cdots + a_0 \pmod m.

The whole game is computing 10^i \bmod m for each i. Let's do it for the classic divisors.

Mod 3 and mod 9: powers of 10 collapse to 1

10 \equiv 1 \pmod 3, so 10^i \equiv 1^i = 1 \pmod 3 for every i. Plugging into the formula:

N \equiv a_k + a_{k-1} + \cdots + a_0 \pmod 3.

The digit sum is congruent to N modulo 3. So N is divisible by 3 iff its digit sum is. Exactly the same argument gives the rule for 9, because 10 \equiv 1 \pmod 9 too.

Why: the powers of 10 all reduce to the same residue, so the place values don't matter — only the digits do. That is exactly what "add the digits" captures.

Mod 11: powers of 10 alternate between 1 and -1

10 \equiv -1 \pmod{11}, so 10^i \equiv (-1)^i \pmod{11}: alternating 1, -1, 1, -1, \ldots

Plugging in:

N \equiv a_0 - a_1 + a_2 - a_3 + \cdots \pmod{11}.

The alternating digit sum is congruent to N modulo 11. That's the alternating-sum rule exactly.

Mod 4 and mod 8: high powers of 10 vanish

10^2 = 100 = 25 \cdot 4, so 10^i \equiv 0 \pmod 4 for i \geq 2. The formula collapses:

N \equiv a_1 \cdot 10 + a_0 \pmod 4.

Only the last two digits matter. Same logic for 8: since 10^3 = 1000 = 125 \cdot 8, powers \geq 3 vanish, so only the last three digits matter.

Mod 5 and mod 10: even simpler

10 \equiv 0 \pmod 5, so every positive power of 10 vanishes mod 5, leaving just a_0. The last digit determines divisibility by 5. Same for 10, trivially.

The master pattern

Every divisibility rule is answering the same question: what do powers of 10 look like mod m? And the shape of those powers determines the shape of the rule.

Divisor m 10^i \bmod m Resulting rule
2 0 for i \geq 1 Last digit
3 1 always Digit sum
4 0 for i \geq 2 Last two digits
5 0 for i \geq 1 Last digit
8 0 for i \geq 3 Last three digits
9 1 always Digit sum
10 0 for i \geq 1 Last digit
11 (-1)^i Alternating digit sum
7 Cycles 1, 3, 2, 6, 4, 5, \ldots No clean rule (cycle too long)

Notice 7 in the last row. Its rule is messy — you would multiply each digit by the appropriate entry of the cycle 1, 3, 2, 6, 4, 5, 1, 3, \ldots and sum. That is why no one memorises "the rule for 7": there is no clean pattern to remember, because the powers of 10 mod 7 form a genuinely random-looking length-6 cycle.

Interactive: see the powers of 10 dictate the rule

Slide through common divisors. For each one, the canvas computes the first few powers $10^i \bmod m$ (real math, not a lookup table), colours them, and shows the rule they produce. When $10 \equiv 1 \pmod m$ every digit counts equally; when the powers vanish quickly you only look at the last few digits; when they alternate you take the alternating sum. The rule *is* the pattern.

Using, then proving

The two-step reflex to build:

  1. Use the rule. When a problem needs you to test divisibility by 3, 9, or 11, apply the digit-based shortcut immediately. No wasted computation.
  2. Remember why. When a proof asks "show N is divisible by …," you often need to convert the digit-based statement back into a congruence. The rule is the shortcut; the congruence is the reason.

Problem. Show that every integer of the form \overline{abcabc} (a 6-digit number with repeating 3-digit block) is divisible by 7, 11, and 13.

Using divisibility rules: You can notice that \overline{abcabc} = \overline{abc} \cdot 1001. And 1001 = 7 \cdot 11 \cdot 13. So \overline{abcabc} is 1001 \cdot k, which is divisible by 7, 11, and 13.

Proving it with modular arithmetic: In symbols, \overline{abcabc} = 1000 \cdot \overline{abc} + \overline{abc} = 1001 \cdot \overline{abc}. Since 1001 = 7 \cdot 11 \cdot 13, the number is divisible by each.

The divisibility rule for 11 (alternating sum) gives you the answer almost instantly: digits are a, b, c, a, b, c, alternating sum is a - b + c - a + b - c = 0, and 0 is divisible by 11. So the 11 part of the answer falls out of the rule without even factoring 1001.

Why this reflex matters

Students often memorise rules without knowing why they work, which means:

Once you see that each rule is a shortcut for "N \bmod m," you get the last bullet for free. The rule is the shortcut; the real engine is the congruence.

Bonus: build a divisibility rule for 99

Applying the formula: 100 \equiv 1 \pmod{99}, so 100^i \equiv 1 for all i. Split N into two-digit blocks from the right, and the sum of those two-digit blocks is congruent to N mod 99. Example: 34 \cdot 99 = 3366. Split into 33 and 66: 33 + 66 = 99, divisible by 99. ✓

You just derived a rule nobody taught you, using only the key idea. That is the reflex in action.

One-line takeaway

Divisibility rules for 3, 4, 5, 8, 9, 10, 11 are all special cases of one fact: N \equiv \sum a_i \cdot 10^i \pmod m, and the rule's shape follows from what 10^i \bmod m looks like. Use the rules in computation, but remember the modular identity behind them — it lets you derive rules for any divisor on demand.

Related: Number Theory Basics · Switch to Mod 10 for Last-Digit Problems · gcd = 1 Unlocks Bézout and Inverses · Factor Into Primes First · Try Small Cases First