1. Home
  2. Explore
  3. Mathematics
  4. Numberphile Card Trick

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Numberphile Card Trick

Divisibility Rules: From Basic to General


1. The Digit Sum Rule for 3 and 9

If the sum of the digits (also called the cross sum) of a number is divisible by 3 or by 9, then the number itself is divisible by 3 or 9, respectively. This is the most fundamental divisibility rule and the basis for the card tricks demonstrated.

Proof:

Let a number NNN have digits an,an−1,…,a1,a0a_n, a_{n-1}, \dots, a_1, a_0an​,an−1​,…,a1​,a0​ (from highest to lowest place).

N=10nan+10n−1an−1+⋯+10a1+a0N = 10^n a_n + 10^{n-1} a_{n-1} + \cdots + 10 a_1 + a_0N=10nan​+10n−1an−1​+⋯+10a1​+a0​

The cross sum T(N)T(N)T(N) is:

T(N)=an+an−1+⋯+a1+a0T(N) = a_n + a_{n-1} + \cdots + a_1 + a_0T(N)=an​+an−1​+⋯+a1​+a0​

Now subtract T(N)T(N)T(N) from NNN:

N−T(N)=(10n−1)an+(10n−1−1)an−1+⋯+(10−1)a1+(a0−a0)N - T(N) = (10^n - 1)a_n + (10^{n-1} - 1)a_{n-1} + \cdots + (10 - 1)a_1 + (a_0 - a_0)N−T(N)=(10n−1)an​+(10n−1−1)an−1​+⋯+(10−1)a1​+(a0​−a0​)

Each term (10k−1)(10^k - 1)(10k−1) is a repunit of 9s (e.g., 102−1=9910^2 - 1 = 99102−1=99, 101−1=910^1 - 1 = 9101−1=9). Thus N−T(N)N - T(N)N−T(N) is always a multiple of 9:

N−T(N)=9×(some integer)N - T(N) = 9 \times (\text{some integer})N−T(N)=9×(some integer)

Therefore, if T(N)T(N)T(N) is divisible by 9, then NNN is divisible by 9. Similarly, if T(N)T(N)T(N) is divisible by 3, then NNN is divisible by 3 (since N−T(N)N - T(N)N−T(N) is already divisible by 3).

Key takeaway: The digit sum rule works for 3 and 9 because the difference N−T(N)N - T(N)N−T(N) is always divisible by 9 (and hence by 3). No other divisor has this property.

Example – Card Trick with Numbers 1–9: Take all nine cards numbered 1 through 9. Their sum is 1+2+⋯+9=451+2+\cdots+9 = 451+2+⋯+9=45, which is divisible by 9. No matter how the cards are arranged, the resulting number will always be divisible by 9. For instance, the arrangement 9,4,5,1,3,6,8,7,2 yields 945,136,872945{,}136{,}872945,136,872, which indeed is a multiple of 9.

Example – Adding a Card to Force Divisibility by 3: If the cards 1,2,3,4 are used in any order, the digit sum is always 1+2+3+4=101+2+3+4 = 101+2+3+4=10, which is not divisible by 3. No arrangement of those four cards can be a multiple of 3. However, adding a card with the number 5 makes the digit sum 10+5=1510+5 = 1510+5=15, which is divisible by 3. Then any arrangement of the five cards (including the 5) is guaranteed to be divisible by 3.

Real-World Application – Belphegor’s Prime: A number of the form 100…0⏟n zeros61600…0⏟n zeros11\underbrace{00\dots0}_{n\text{ zeros}}616\underbrace{00\dots0}_{n\text{ zeros}}11n zeros00…0​​616n zeros00…0​​1 has a digit sum of 1+6+1+6+1=151+6+1+6+1 = 151+6+1+6+1=15. Since 15 is divisible by 3, the whole number is always divisible by 3, and therefore can never be prime (except possibly 3 itself, which it isn’t). A computer search for primes of this form was futile because the digit sum rule was overlooked.


2. Divisibility by 2, 4, 5, 8, and 10

These rules rely on the fact that certain powers of 10 are divisible by the divisor.

  • 2: The number must be even: its last digit is 0, 2, 4, 6, or 8.

  • 4: Check the last two digits. If the two‑digit number formed by the last two digits is divisible by 4, then the whole number is divisible by 4. (Reason: 100100100, 100010001000, etc., are multiples of 4.)

  • 5: The last digit must be 0 or 5.

  • 10: The last digit must be 0.

  • 8: Check the last three digits. If the three‑digit number formed by the last three digits is divisible by 8, then the whole number is divisible by 8. (Reason: 100010001000, 100001000010000, etc., are multiples of 8.)

A quick three‑digit test for divisibility by 8:

For a three‑digit number N=100a+10b+cN = 100a + 10b + cN=100a+10b+c, compute:

T(N)=2(10a+b)+c=20a+2b+cT(N) = 2(10a + b) + c = 20a + 2b + cT(N)=2(10a+b)+c=20a+2b+c

If T(N)T(N)T(N) is divisible by 8, then NNN is divisible by 8.

Proof:

N−T(N)=(100a+10b+c)−(20a+2b+c)=80a+8b=8(10a+b)N - T(N) = (100a + 10b + c) - (20a + 2b + c) = 80a + 8b = 8(10a + b)N−T(N)=(100a+10b+c)−(20a+2b+c)=80a+8b=8(10a+b)

Since N−T(N)N - T(N)N−T(N) is always a multiple of 8, if T(N)T(N)T(N) is divisible by 8, so is NNN.

Example: Check 464464464 – last three digits are 464464464. T(464)=2(46)+4=92+4=96T(464) = 2(46) + 4 = 92 + 4 = 96T(464)=2(46)+4=92+4=96, which is divisible by 8. Hence 464464464 is divisible by 8.


3. Divisibility by 6 and 12 (Composite Rules)

  • 6: The number must satisfy the rules for both 2 and 3 (i.e., even and digit sum divisible by 3).

  • 12: The number must satisfy the rules for both 4 and 3 (i.e., last two digits divisible by 3? Actually last two digits divisible by 4 and digit sum divisible by 3). Equivalent to passing the tests for 3 and 4.


4. Divisibility by 11

Rule: Reverse the digits of the number, then compute the alternating sum of the digits (starting from the first digit of the reversed number). If the result is a multiple of 11 (including 0), then the original number is a multiple of 11.

Explanation: Let the number be NNN with digits dndn−1…d0d_n d_{n-1} \dots d_0dn​dn−1​…d0​. Its reverse is d0d1…dnd_0 d_1 \dots d_nd0​d1​…dn​. Compute:

Alternating sum=d0−d1+d2−d3+⋯\text{Alternating sum} = d_0 - d_1 + d_2 - d_3 + \cdotsAlternating sum=d0​−d1​+d2​−d3​+⋯

If this alternating sum is 000 or any multiple of 111111, then 111111 divides NNN.

Proof sketch: The test works because 10≡−1(mod11)10 \equiv -1 \pmod{11}10≡−1(mod11), so powers of 10 alternate between 111 and −1-1−1 modulo 11.

Example: Number 121121121 – reverse 121121121, alternating sum 1−2+1=01 - 2 + 1 = 01−2+1=0, so 121121121 is divisible by 111111 (121=11×11121 = 11 \times 11121=11×11).
Number 132132132 – reverse 231231231, alternating sum 2−3+1=02 - 3 + 1 = 02−3+1=0, divisible by 111111 (132=11×12132 = 11 \times 12132=11×12).

Card Trick Application: Given a five‑digit number that is not a multiple of 11, one can add a single digit to make it a multiple of 11. Compute the alternating sum of the reversed number; the result (call it rrr) is not a multiple of 11. Adding a digit at the beginning (which changes the alternating sum in a predictable way) can bring the sum to 000 or 111111. For a precise method: if the alternating sum of the reversed number is sss, then inserting a digit xxx at the front changes the alternating sum to x−sx - sx−s (because the new first digit appears with positive sign). Setting x=sx = sx=s gives 000. In the demonstration, the original number gave alternating sum 555, so adding a 555 at the front made the new number divisible by 11.


5. Divisibility by 7

The number 7 is famous for having no simple digit‑sum rule. Two reliable tests are commonly used.

5.1 Block Method (Alternating Sum of Groups of Three)

Procedure:

  1. Starting from the right, group the digits into blocks of three.

  2. Compute an alternating sum of these blocks: add the first block (rightmost), subtract the second, add the third, subtract the fourth, and so on.

  3. If the result is divisible by 7, then the original number is divisible by 7.

Why it works: The number 1001=7×11×131001 = 7 \times 11 \times 131001=7×11×13 and 999,999=7×142,857999{,}999 = 7 \times 142{,}857999,999=7×142,857 are both multiples of 7. These facts make the block‑wise alternation valid.

Example: Number 984,976,006984{,}976{,}006984,976,006 – blocks: 984984984, 976976976, 006006006 (as 666). Alternating sum: 984−976+6=14984 - 976 + 6 = 14984−976+6=14. Since 141414 is a multiple of 7, the original number is divisible by 7.

Note: The result of the alternating sum may be a three‑digit number that is not obviously a multiple of 7. In that case, use the three‑digit test below.

5.2 Three‑Digit Test for 7

For a three‑digit number N=100a+10b+cN = 100a + 10b + cN=100a+10b+c, compute:

T(N)=(10a+b)−2cT(N) = (10a + b) - 2cT(N)=(10a+b)−2c

If T(N)T(N)T(N) is divisible by 7, then NNN is divisible by 7.

Proof:

N−T(N)=(100a+10b+c)−(10a+b−2c)=90a+9b+3c=3(30a+3b+c)N - T(N) = (100a + 10b + c) - (10a + b - 2c) = 90a + 9b + 3c = 3(30a + 3b + c)N−T(N)=(100a+10b+c)−(10a+b−2c)=90a+9b+3c=3(30a+3b+c)

This is not obviously a multiple of 7, but the test can be verified by trying all residues modulo 7. A cleaner proof uses the fact that 100a+10b+c≡(10a+b)−2c(mod7)100a + 10b + c \equiv (10a + b) - 2c \pmod{7}100a+10b+c≡(10a+b)−2c(mod7) because 10≡3(mod7)10 \equiv 3 \pmod{7}10≡3(mod7) and 100≡2(mod7)100 \equiv 2 \pmod{7}100≡2(mod7).

Example: 749749749: T=74−2×9=74−18=56T = 74 - 2 \times 9 = 74 - 18 = 56T=74−2×9=74−18=56, which is divisible by 7, so 749749749 is divisible by 777 (749=7×107749 = 7 \times 107749=7×107).


6. General Divisibility Test for Divisors Ending in 1, 3, 7, or 9

This method works for any divisor ddd that is not divisible by 2 or 5 (i.e., ends in 1, 3, 7, or 9). It reduces the problem to checking a smaller number.

Step 1: Find the “Divvy Number” mmm

  • Multiply ddd by the smallest integer so that the product ends in 9.

  • Add 1 to that product (now it ends in 0 and is a multiple of 10).

  • Divide by 10 to obtain mmm.

Step 2: Apply the Test

Write the number NNN to be tested as N=10t+qN = 10t + qN=10t+q, where qqq is the last digit (0–9) and ttt is the rest of the number.

Compute:

N′=t+m⋅qN' = t + m \cdot qN′=t+m⋅q

If N′N'N′ is divisible by ddd, then NNN is divisible by ddd. This step can be repeated if N′N'N′ is still large.

Why it works: The transformation 10t+q→t+mq10t + q \rightarrow t + mq10t+q→t+mq is equivalent to multiplying by an appropriate factor modulo ddd, exploiting the fact that 10m≡−1(modd)10m \equiv -1 \pmod{d}10m≡−1(modd) after the construction.

Example – Divisor 23:

  • d=23d = 23d=23 ends in 3. Multiply by 3 to get 696969 (ends in 9).

  • Add 111 → 707070.

  • Divide by 101010 → m=7m = 7m=7.

Test N=1035N = 1035N=1035 (which is 23×4523 \times 4523×45).

Write N=10×103+5N = 10 \times 103 + 5N=10×103+5, so t=103t = 103t=103, q=5q = 5q=5.

Compute N′=103+7×5=103+35=138N' = 103 + 7 \times 5 = 103 + 35 = 138N′=103+7×5=103+35=138.

Now 138138138 is divisible by 232323? 23×6=13823 \times 6 = 13823×6=138, yes. Therefore 103510351035 is divisible by 232323.

Example – Divisor 13:

  • d=13d = 13d=13 ends in 3. Multiply by 3 → 393939 (ends in 9).

  • Add 111 → 404040.

  • Divide by 101010 → m=4m = 4m=4.

Test N=169N = 169N=169 (13×1313 \times 1313×13). 169=10×16+9169 = 10 \times 16 + 9169=10×16+9 → t=16,q=9t=16, q=9t=16,q=9.
N′=16+4×9=16+36=52N' = 16 + 4 \times 9 = 16 + 36 = 52N′=16+4×9=16+36=52. 525252 is divisible by 131313 (13×413 \times 413×4), so 169169169 is divisible by 131313.

Limitations: This method works only when the divisor ends in 1, 3, 7, or 9 because only then can it be multiplied to end in 9 (the target for the trick). Divisors ending in 0,2,4,5,6,8 can be handled by the simpler rules above or by first removing factors of 2 and 5.


7. Summary of Divisibility Rules

Below is a quick‑reference list of all rules covered.

  • 1: Every integer is divisible by 1.

  • 2: Last digit is even.

  • 3: Digit sum is divisible by 3.

  • 4: Last two digits form a number divisible by 4.

  • 5: Last digit is 0 or 5.

  • 6: Passes tests for 2 and 3.

  • 7: Block method (alternating sum of groups of three) or three‑digit test (10a+b−2c10a+b-2c10a+b−2c).

  • 8: Last three digits divisible by 8 (or use the 2(10a+b)+c2(10a+b)+c2(10a+b)+c test for three digits).

  • 9: Digit sum divisible by 9.

  • 10: Last digit is 0.

  • 11: Reverse the number, take alternating sum; result is multiple of 11.

  • 12: Passes tests for 3 and 4.

  • General (d ending in 1,3,7,9): Compute mmm from ddd as described, then repeatedly apply N=10t+q→t+mqN = 10t+q \rightarrow t + mqN=10t+q→t+mq until a small number is obtained; if that small number is divisible by ddd, then the original is.

The digit sum rules for 3 and 9 are the most elegant and widely applicable, while the general test demonstrates the power of modular arithmetic in simplifying divisibility checks. Understanding these rules enhances number sense and provides efficient shortcuts for mental arithmetic.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent