Sub topic 11
Divisibility rules for 3, 9, 11 and friends
This chapter assumes you can work with remainders, know place value (a digit times a power of 10), and can solve a simple linear equation. You will see why the digit-based tests work, how to extend them to 7, 13 and composite numbers, and how to use them on CAT-style problems with a missing digit.
Why digit tests work at all
Write a number by place value: 7384 = 7·1000 + 3·100 + 8·10 + 4. A divisibility test works when the powers of 10 leave a simple pattern of remainders for the divisor.
| Divisor | Pattern of 10, 100, 1000, ... | What follows |
|---|---|---|
| 2, 5 | 10 is a multiple | Only the last digit matters |
| 4, 25 | 100 is a multiple | Only the last two digits matter |
| 8, 125 | 1000 is a multiple | Only the last three digits matter |
| 3, 9 | 10 leaves remainder 1, so every power of 10 does | Add the digits |
| 11 | 10 leaves remainder -1, so powers alternate +1, -1, +1, ... | Alternate the signs of the digits |
| 7, 11, 13 | 1000 leaves remainder -1 modulo 1001 (1001 = 7·11·13) | Alternate the sums of 3-digit blocks |
The reasoning for 9 is short. Each power of 10 equals 1 plus a multiple of 9, so 7·1000 + 3·100 + 8·10 + 4 equals (7 + 3 + 8 + 4) plus a multiple of 9. A number and its digit sum therefore leave the same remainder on division by 9, and the same holds for 3.
The rules for 2, 4, 5, 8, 25 and 125
These rules look only at the end of the number.
- 2, 4, 8: the last 1, 2 or 3 digits form a number divisible by 2, 4 or 8.
- 5, 25, 125: the last 1, 2 or 3 digits form a number divisible by 5, 25 or 125.
For example, 5,672 is divisible by 8 because 672 = 8·84. It is not divisible by 16 by this rule alone, because 16 divides 10,000 and not 1000, so you would need four digits.
The rules for 3 and 9
Add the digits. If the sum is divisible by 3, so is the number. If the sum is divisible by 9, so is the number.
The digit sum also gives the remainder, not just a yes or no. The number 7384 has digit sum 22, and 22 leaves remainder 4 on division by 9, so 7384 leaves remainder 4 too. For the remainder on division by 3, take the digit sum modulo 3.
You can repeat the digit sum until one digit remains, which is the idea behind casting out nines. A single digit of 9 means remainder 0.
The rule for 11
Number the digits from the right. Add the digits in odd positions, add the digits in even positions, and subtract. If the difference is 0 or a multiple of 11, the number is divisible by 11.
Take 91,839. From the right the digits are 9, 3, 8, 1, 9. The alternating sum is 9 - 3 + 8 - 1 + 9 = 22, which is a multiple of 11. Dividing confirms it: 91,839 = 11 · 8349.
The alternating sum gives the remainder modulo 11 as well, but it may be negative. Add 11 until the result lies between 0 and 10. Starting the alternation from the left instead of the right only changes the sign of the result, so divisibility is unaffected, but a remainder would be wrong. Always start at the units digit when you want a remainder.
The rule for 7 and 13 using 1001
Since 1001 = 7 · 11 · 13, and 1000 leaves remainder -1 modulo 1001, split the number into blocks of three digits from the right. Subtract and add the blocks alternately. The result has the same remainder as the original number modulo 7, 11 and 13.
For 483,672 the blocks are 483 and 672. The alternating sum is 672 - 483 = 189.
- 189 = 7 · 27, so 483,672 is divisible by 7.
- 189 is not divisible by 11 or 13, so 483,672 is not.
Division confirms it: 483,672 = 7 · 69,096.
This is slower than the rules for 3, 9 and 11. Use it only when the number is long and the rest of the question has no cheaper route.
Checking the rules in code
The functions below compute the digit sum, the alternating sum and the block sum. The loops compare each against the true remainder for every number from 1 to 99,999.
def digit_sum(n):
return sum(int(d) for d in str(n))
def alt_sum(n):
# digits taken from the right, signs +, -, +, ...
return sum(int(d) * (-1) ** i for i, d in enumerate(reversed(str(n))))
def block_alt_sum(n):
s, total, i = str(n), 0, 0
while s:
total += int(s[-3:]) * (-1) ** i
s = s[:-3]
i += 1
return total
print(digit_sum(7384), 7384 % 9) # 22 4
print(alt_sum(91839), block_alt_sum(483672)) # 22 189
print(all(digit_sum(n) % 9 == n % 9 for n in range(1, 100000)))
print(all(alt_sum(n) % 11 == n % 11 for n in range(1, 100000)))
print(all(block_alt_sum(n) % 7 == n % 7 and block_alt_sum(n) % 13 == n % 13
for n in range(1, 100000)))The three final lines each print True. Python's % returns a non-negative result for a positive modulus, so a negative alternating sum still compares correctly.
Composite divisors: combine coprime tests
To test a composite divisor, split it into factors that share no common factor, then test each one.
- 6 = 2 · 3: last digit even and digit sum divisible by 3.
- 12 = 3 · 4: digit sum divisible by 3 and last two digits divisible by 4.
- 18 = 2 · 9, 36 = 4 · 9, 72 = 8 · 9.
- 99 = 9 · 11 and 33 = 3 · 11.
Choosing a rule
Missing digit problems
Many CAT questions give a number with an unknown digit and ask for a value that satisfies a divisibility condition.
Example 1. Find the digit x so that 52x1 is divisible by 11. From the right the digits are 1, x, 2, 5. The alternating sum is 1 - x + 2 - 5 = -2 - x. It must be a multiple of 11, so x = 9 gives -11. Check: 5291 = 11 · 481.
Example 2. Find x so that 4x73 is divisible by 11. The alternating sum is 3 - 7 + x - 4 = x - 8. The only digit that makes this a multiple of 11 is x = 8, which gives 0. Check: 4873 = 11 · 443.
Example 3. Find the digits so that 7a4b2 is divisible by 9, and list the possible values of a + b. The digit sum is 7 + a + 4 + b + 2 = 13 + a + b. It must be 18 or 27, so a + b = 5 or 14. If a second condition fixes a, the digit b follows from the sum.
When two unknown digits appear in a number being tested for 11, the alternating sum becomes an equation in two unknowns. Use the constraint that each digit is between 0 and 9 to limit the cases. For a digit-sum test for 9 the unknowns appear only as their sum, so you can list the possibilities directly.
Remainders from the same ideas
You do not need to find a number divisible by the divisor. The digit sum and alternating sum give the remainder directly.
- Remainder of 98,765 modulo 9: the digit sum is 35, then 3 + 5 = 8, so the remainder is 8.
- Remainder of 98,765 modulo 11: from the right, 5 - 6 + 7 - 8 + 9 = 7, so the remainder is 7.
Both can be checked by long division: 98,765 = 9 · 10,973 + 8 and 98,765 = 11 · 8978 + 7.
The same rules in other bases
The reason a rule works is that b leaves remainder 1 on division by b - 1 and remainder -1 on division by b + 1. This holds in every base b.
- In base b, the digit sum tests divisibility by b - 1 and its factors.
- In base b, the alternating sum tests divisibility by b + 1 and its factors.
Take 213 in base 5, which is 58 in decimal. The digit sum is 2 + 1 + 3 = 6, and 58 and 6 both leave remainder 2 on division by 4. The alternating sum is 3 - 1 + 2 = 4, and 58 leaves remainder 4 on division by 6. Both checks agree.
Common mistakes
- Mixing the signs for 11. Start at the units digit with a plus sign when you need a remainder. For a yes or no answer the direction does not matter.
- Stopping at a non-zero single digit for 11. The alternating sum can be 11, 22, -11 and so on. Only multiples of 11 pass, including 0.
- Using non-coprime factors. See the warning above.
- Applying the 9 rule to 3 questions. A digit sum of 12 shows divisibility by 3 and not by 9.
- Forgetting the one-digit bound. Unknown digits are 0 to 9, and a leading digit is not 0. These limits often leave a single answer.
Exercise
Find the digit x for which the number 4x73 is divisible by 11, and give the quotient.
Show answer
From the right, 3 - 7 + x - 4 = x - 8 must be a multiple of 11, so x = 8. The number is 4873, and 4873 / 11 = 443.
Exercise
Find the remainder when 98,765 is divided by 9, and when it is divided by 11.
Show answer
The digit sum is 9 + 8 + 7 + 6 + 5 = 35, which gives 3 + 5 = 8, so the remainder modulo 9 is 8. The alternating sum from the right is 5 - 6 + 7 - 8 + 9 = 7, so the remainder modulo 11 is 7.
Exercise
Give a number divisible by both 4 and 6 that is not divisible by 24, and explain why testing 4 and 6 separately is not a valid test for 24.
Show answer
The number 12 works, as does 36. Both divide by 4 and by 6 and neither divides by 24. The factors 4 and 6 share a factor of 2, so passing both tests does not make a number divisible by their product. Test 3 and 8 instead, which are coprime.