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 N have digits an,an−1,…,a1,a0 (from highest to lowest place).
The cross sum T(N) is:
Now subtract T(N) from N:
Each term (10k−1) is a repunit of 9s (e.g., 102−1=99, 101−1=9). Thus N−T(N) is always a multiple of 9:
Therefore, if T(N) is divisible by 9, then N is divisible by 9. Similarly, if T(N) is divisible by 3, then N is divisible by 3 (since 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) 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=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,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=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=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 1n zeros00…0616n zeros00…01 has a digit sum of 1+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: 100, 1000, 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: 1000, 10000, etc., are multiples of 8.)
A quick three‑digit test for divisibility by 8:
For a three‑digit number N=100a+10b+c, compute:
If T(N) is divisible by 8, then N is divisible by 8.
Proof:
Since N−T(N) is always a multiple of 8, if T(N) is divisible by 8, so is N.
Example: Check 464 – last three digits are 464. T(464)=2(46)+4=92+4=96, which is divisible by 8. Hence 464 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 N with digits dndn−1…d0. Its reverse is d0d1…dn. Compute:
If this alternating sum is 0 or any multiple of 11, then 11 divides N.
Proof sketch: The test works because 10≡−1(mod11), so powers of 10 alternate between 1 and −1 modulo 11.
Example: Number 121 – reverse 121, alternating sum 1−2+1=0, so 121 is divisible by 11 (121=11×11).
Number 132 – reverse 231, alternating sum 2−3+1=0, divisible by 11 (132=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 r) 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 0 or 11. For a precise method: if the alternating sum of the reversed number is s, then inserting a digit x at the front changes the alternating sum to x−s (because the new first digit appears with positive sign). Setting x=s gives 0. In the demonstration, the original number gave alternating sum 5, so adding a 5 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:
Starting from the right, group the digits into blocks of three.
Compute an alternating sum of these blocks: add the first block (rightmost), subtract the second, add the third, subtract the fourth, and so on.
If the result is divisible by 7, then the original number is divisible by 7.
Why it works: The number 1001=7×11×13 and 999,999=7×142,857 are both multiples of 7. These facts make the block‑wise alternation valid.
Example: Number 984,976,006 – blocks: 984, 976, 006 (as 6). Alternating sum: 984−976+6=14. Since 14 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+c, compute:
If T(N) is divisible by 7, then N is divisible by 7.
Proof:
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) because 10≡3(mod7) and 100≡2(mod7).
Example: 749: T=74−2×9=74−18=56, which is divisible by 7, so 749 is divisible by 7 (749=7×107).
6. General Divisibility Test for Divisors Ending in 1, 3, 7, or 9
This method works for any divisor d 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” m
Multiply d 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 m.
Step 2: Apply the Test
Write the number N to be tested as N=10t+q, where q is the last digit (0–9) and t is the rest of the number.
Compute:
If N′ is divisible by d, then N is divisible by d. This step can be repeated if N′ is still large.
Why it works: The transformation 10t+q→t+mq is equivalent to multiplying by an appropriate factor modulo d, exploiting the fact that 10m≡−1(modd) after the construction.
Example – Divisor 23:
d=23 ends in 3. Multiply by 3 to get 69 (ends in 9).
Add 1 → 70.
Divide by 10 → m=7.
Test N=1035 (which is 23×45).
Write N=10×103+5, so t=103, q=5.
Compute N′=103+7×5=103+35=138.
Now 138 is divisible by 23? 23×6=138, yes. Therefore 1035 is divisible by 23.
Example – Divisor 13:
d=13 ends in 3. Multiply by 3 → 39 (ends in 9).
Add 1 → 40.
Divide by 10 → m=4.
Test N=169 (13×13). 169=10×16+9 → t=16,q=9.
N′=16+4×9=16+36=52. 52 is divisible by 13 (13×4), so 169 is divisible by 13.
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−2c).
8: Last three digits divisible by 8 (or use the 2(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 m from d as described, then repeatedly apply N=10t+q→t+mq until a small number is obtained; if that small number is divisible by d, 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.