Sub topic 2
Divisibility rules for 2 to 13
This chapter assumes you can do division with remainder, read exponent notation, and handle basic algebra. It gives you a test for each divisor from 2 to 13. You can use these tests to check whether a number is divisible without dividing it. They also tell you which of 2, 3, 5, 7, 11 and 13 appear in a number's prime factorization, which later chapters need. The chapter covers each rule, why it works, how to combine rules, and the mistakes CAT questions try to trigger.
The rules at a glance
A number N is divisible by d if dividing N by d leaves remainder 0. Each rule below replaces that division with a cheaper check on the digits.
| Divisor | Test | Example |
|---|---|---|
| 2 | Last digit is 0, 2, 4, 6 or 8 | 3,846 |
| 3 | Sum of digits is divisible by 3 | 4,572 (4+5+7+2 = 18) |
| 4 | Last two digits form a number divisible by 4 | 7,316 (16) |
| 5 | Last digit is 0 or 5 | 2,805 |
| 6 | Divisible by both 2 and 3 | 5,418 (even, digit sum 18) |
| 7 | Remove the last digit, subtract twice it from the rest, repeat | 2,415 |
| 8 | Last three digits form a number divisible by 8 | 5,128 (128) |
| 9 | Sum of digits is divisible by 9 | 6,381 (18) |
| 10 | Last digit is 0 | 4,970 |
| 11 | Alternating digit sum is 0 or a multiple of 11 | 2,728 (8-2+7-2 = 11) |
| 12 | Divisible by both 3 and 4 | 3,684 |
| 13 | Remove the last digit, add 4 times it to the rest, repeat | 2,535 |
Why the rules work
Each rule follows from how powers of 10 behave. Write a number such as 4,572 as 4×1000 + 5×100 + 7×10 + 2.
- Rules for 2, 5 and 10. Every power of 10 from 10 upward is divisible by 2, 5 and 10. Only the last digit can change the answer.
- Rule for 4. 100 is divisible by 4, so only the last two digits matter. For the same reason, 1000 is divisible by 8, so only the last three digits matter for 8.
- Rules for 3 and 9. 10, 100, 1000 and so on each leave remainder 1 when divided by 9 (and by 3). A number therefore leaves the same remainder as its digit sum. This also means the digit sum gives the actual remainder mod 9, not just a yes or no.
- Rule for 11. 10 leaves remainder -1 (that is, 10 = 11 - 1), so 10², 10³ and so on alternate between +1 and -1. This is why the digits are added and subtracted alternately, starting from the right.
The 7, 11, 13 group trick
Note that 1001 = 7 × 11 × 13. So 1000 leaves remainder -1 when divided by each of 7, 11 and 13. Split the number into groups of three digits from the right. Then add and subtract the groups alternately, starting with a plus on the rightmost group. The result has the same remainder as N for each of 7, 11 and 13.
For 123,456,789 the groups give 789 - 456 + 123 = 456. Now 456 = 7×65 + 1, 456 = 11×41 + 5, and 456 = 13×35 + 1. So 123,456,789 leaves remainders 1, 5 and 1 when divided by 7, 11 and 13 respectively.
The digit-by-digit rules for 7 and 13 in the table also work, and they are easier on short numbers:
- Check 2,415 for 7. The rest is 241 and the last digit is 5. Then 241 - 10 = 231. Next, 23 - 2×1 = 21. Since 21 is divisible by 7, so is 2,415 (2415 = 7 × 345).
- Check 2,535 for 13. The rest is 253 and the last digit is 5. Then 253 + 20 = 273. Next, 27 + 4×3 = 39. Since 39 = 13×3, the number 2,535 is divisible by 13 (2535 = 13 × 195).
Stop as soon as you reach a number you recognize as a multiple of 7 or 13.
Combining rules
To test divisibility by a composite number, split it into factors that are coprime (share no common factor other than 1). Then test each factor separately. If N passes every test, it is divisible by the composite.
- 6 = 2 × 3
- 12 = 3 × 4
- 15 = 3 × 5
- 18 = 2 × 9
- 24 = 3 × 8
- 72 = 8 × 9
A CAT-style example: finding a missing digit
Find all digits x for which the number 62x4 is divisible by 12.
Split 12 into 3 and 4, which are coprime.
- Test for 4. The last two digits are x4. The values 04, 24, 44, 64 and 84 are divisible by 4, and 14, 34, 54, 74 and 94 are not. So x must be even.
- Test for 3. The digit sum is 6 + 2 + x + 4 = 12 + x. So 12 + x must be divisible by 3, which means x ∈ {0, 3, 6, 9}.
- Combine. The even values in that set are 0 and 6.
So x = 0 or x = 6. Check: 6204 = 12 × 517 and 6264 = 12 × 522.
Checking the rules in code
The program below implements the digit-based tests and compares each one with direct division for every number from 1 to 20,000.
def digit_sum(n):
return sum(int(c) for c in str(n))
def alt_digit_sum(n):
# Digits from the right, signs +, -, +, ...
return sum(int(c) * (1 if i % 2 == 0 else -1)
for i, c in enumerate(reversed(str(n))))
def alt_group_sum(n):
# Groups of three digits from the right, signs +, -, +, ...
total, sign = 0, 1
while n:
total += sign * (n % 1000)
n //= 1000
sign = -sign
return total
rules = {
2: lambda n: n % 10 in (0, 2, 4, 6, 8),
3: lambda n: digit_sum(n) % 3 == 0,
4: lambda n: (n % 100) % 4 == 0,
5: lambda n: n % 10 in (0, 5),
7: lambda n: alt_group_sum(n) % 7 == 0,
8: lambda n: (n % 1000) % 8 == 0,
9: lambda n: digit_sum(n) % 9 == 0,
10: lambda n: n % 10 == 0,
11: lambda n: alt_digit_sum(n) % 11 == 0,
13: lambda n: alt_group_sum(n) % 13 == 0,
}
rules[6] = lambda n: rules[2](n) and rules[3](n)
rules[12] = lambda n: rules[3](n) and rules[4](n)
ok = all(rule(n) == (n % d == 0)
for d, rule in rules.items()
for n in range(1, 20001))
print(ok) # True
print(alt_group_sum(123456789)) # 456Common errors
- Wrong sign start in the 11 rule. The test only needs the total to be 0 or a multiple of 11. So starting the alternation from the left or the right gives the same verdict, but mixing the two halfway through does not.
- Forgetting that 0 counts. If the alternating sum is 0, the number is divisible by 11. For example, 9,449 gives 9 - 4 + 4 - 9 = 0.
- Using the digit sum for the wrong divisor. The digit sum test works for 3 and 9 only. It says nothing about 6 or 12 on its own.
- Using too few digits. For 8 you need the last three digits, not two. For example, 1,004 ends in 04, which is divisible by 4, but 1,004 ÷ 8 leaves remainder 4.
- Stopping the 7 or 13 reduction too early. If the reduced number is not obviously a multiple, apply the step again.
Where this leads
These tests are how you find the first primes in a factorization. For example, 3,684 is divisible by 12 and so by 2 and 3. The next chapters on primes and factorization build on this. Practise reading off the last digit, the last two or three digits, and the digit sum in one pass.
Exercise
The number 7,3x8 is divisible by 8. Which digits x are possible? Then, for which of those digits is the whole number also divisible by 3?
Show answer
For 8 look at the last three digits, 3x8. Check 308, 318, ..., 398 for divisibility by 8: 328 = 8×41, 368 = 8×46 and nothing else works (308 leaves 4, 318 leaves 6, 338 leaves 2, 348 leaves 4, 358 leaves 6, 378 leaves 2, 388 leaves 4, 398 leaves 6). So x = 2 or 6. For 3 the digit sum is 7+3+x+8 = 18+x, so x must be a multiple of 3. Of 2 and 6, only x = 6 works, giving 7,368.
Exercise
Use the 1001 trick to find the remainder when 5,432,109 is divided by 13.
Show answer
Groups from the right are 109, 432 and 5. The alternating sum is 109 - 432 + 5 = -318. Divide -318 by 13: 13 × (-25) = -325, and -318 - (-325) = 7. So the remainder is 7. Check: 5,432,109 = 13 × 417,854 + 7.