HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
Division, Divisibility Rules and Primes
  1. 1The division algorithm and divisibility
  2. 2Divisibility rules and why they work
  3. 3Primes and the fundamental theorem
  1. Mathematics
  2. /Division, Divisibility Rules and Primes
  3. /Divisibility rules and why they work

Course 27.1·Lesson 2 of 3

Divisibility rules and why they work

A number written with digits is a sum of digits times powers of 101010. Each power of 101010 leaves a simple remainder on division by 222, 333

Lesson 2 of 3Show all lessonsHide
Division, Divisibility Rules and Primes
  1. 1The division algorithm and divisibility
  2. 2Divisibility rules and why they work
  3. 3Primes and the fundamental theorem

Try the code and the simulations beside the lesson.

What you will be able to do

  • prove the divisibility rules for 222, 444, 888, 333, 999, 111111, and the joint rule for 777, 111111 and 131313;
  • use the facts a−b∣an−bna - b \mid a^n - b^na−b∣an−bn and, for odd nnn, a+b∣an+bna + b \mid a^n + b^na+b∣an+bn;
  • find missing digits so that a number is divisible by a given number.

Digits are a sum

The number 472647264726 means 4×1000+7×100+2×10+64 \times 1000 + 7 \times 100 + 2 \times 10 + 64×1000+7×100+2×10+6. A number with digits dk,…,d1,d0d_k, \dots, d_1, d_0dk​,…,d1​,d0​ is

N=dk10k+⋯+d1⋅10+d0.\displaystyle N = d_k 10^k + \dots + d_1 \cdot 10 + d_0.N=dk​10k+⋯+d1​⋅10+d0​.

We write it dk…d1d0‾\overline{d_k \dots d_1 d_0}dk​…d1​d0​​, with a bar, so that ab‾\overline{ab}ab is not read as a×ba \times ba×b. Every divisibility rule comes from this sum.

Two factorisations

For any integers aaa and bbb and any whole number n≥1n \ge 1n≥1,

an−bn=(a−b)(an−1+an−2b+⋯+bn−1).\displaystyle a^n - b^n = (a - b)(a^{n-1} + a^{n-2}b + \dots + b^{n-1}).an−bn=(a−b)(an−1+an−2b+⋯+bn−1).

So a−ba - ba−b always divides an−bna^n - b^nan−bn. When nnn is odd, replace bbb by −b-b−b. This gives a+b∣an+bna + b \mid a^n + b^na+b∣an+bn for odd nnn.

The rules for 3 and 9

Take a=10a = 10a=10 and b=1b = 1b=1. Then 9∣10k−19 \mid 10^k - 19∣10k−1 for every kkk. (These numbers are 999, 999999, 999999999, and so on.) Now subtract the digit sum SSS from NNN:

N−S=dk(10k−1)+⋯+d1(10−1).\displaystyle N - S = d_k(10^k - 1) + \dots + d_1(10 - 1).N−S=dk​(10k−1)+⋯+d1​(10−1).

Every bracket is a multiple of 999. So NNN and SSS leave the same remainder on division by 999. In particular 9∣N9 \mid N9∣N exactly when 9∣S9 \mid S9∣S. Since 3∣93 \mid 93∣9, the same holds for 333.

Notice how much more this says than the rule you learnt. It gives the remainder, not only a yes or a no.

The rules for 2, 4 and 8

The number 10k10^k10k is divisible by 2k2^k2k. So every digit from the thousands upwards contributes a multiple of 888. The number NNN leaves the same remainder on division by 888 as its last three digits. In the same way, the last two digits decide divisibility by 444, and the last digit decides divisibility by 222. The same reasoning works for 555, 525^252 and 535^353.

The rule for 11

Take a=10a = 10a=10 and b=−1b = -1b=−1. Then 11∣10k−(−1)k11 \mid 10^k - (-1)^k11∣10k−(−1)k. So 10k10^k10k leaves remainder 111 on division by 111111 when kkk is even, and remainder 101010 when kkk is odd. Think of 101010 as one less than 111111, so it acts like −1-1−1. Hence NNN and the alternating sum

T=d0−d1+d2−d3+…\displaystyle T = d_0 - d_1 + d_2 - d_3 + \dotsT=d0​−d1​+d2​−d3​+…

leave the same remainder on division by 111111. For 472647264726, T=6−2+7−4=7T = 6 - 2 + 7 - 4 = 7T=6−2+7−4=7, and indeed 4726=11×429+74726 = 11 \times 429 + 74726=11×429+7.

The rule for 7, 11 and 13

Here is a fact worth remembering: 1001=7×11×131001 = 7 \times 11 \times 131001=7×11×13. So 100010001000 acts like −1-1−1 for each of these three divisors. Split NNN into groups of three digits from the right, and take the alternating sum of the groups. That sum leaves the same remainder as NNN on division by 777, by 111111 and by 131313.

For example, N=9876543N = 9876543N=9876543 splits as 9∣876∣5439 \mid 876 \mid 5439∣876∣543. The alternating sum is 543−876+9=−324543 - 876 + 9 = -324543−876+9=−324. The program below checks that NNN and −324-324−324 leave the same remainders.

Joining two rules

Suppose a number is divisible by 888 and by 111111. Since 888 and 111111 share no factor bigger than 111, it is divisible by 888888. We use this to find missing digits.

Worked example. Find the digits xxx and yyy for which 3x46y‾\overline{3x46y}3x46y​ is divisible by 888888.

  1. The rule for 8. The last three digits 46y‾\overline{46y}46y​ must be a multiple of 888. The numbers 460460460 to 469469469 contain only one multiple of 888, which is 464464464. So y=4y = 4y=4.
  2. The rule for 11. The alternating sum is 4−6+4−x+3=5−x4 - 6 + 4 - x + 3 = 5 - x4−6+4−x+3=5−x. It must be a multiple of 111111. For a digit xxx that means 5−x=05 - x = 05−x=0, so x=5x = 5x=5.
  3. Check. 35464=88×40335464 = 88 \times 40335464=88×403.

Practise with new numbers

Try it in Python

The program checks the rules for 999 and 111111 on every number up to 100000100000100000. Then it splits 987654398765439876543 into groups of three digits.

Read it first. Then run it. Do both rules hold?

1. Change n = 9876543 to a number of your own. Do the remainders of the group sum match those of the number?

2. The rule for 37 uses 999=27×37999 = 27 \times 37999=27×37. Write a check that adds the groups of three digits without signs.

Common mistakes

  • Reading the rule for 4 as the rule for 2 twice. 343434 is even and 444 is even, yet 343434 is not a multiple of 444. Look at the last two digits as one number.
  • Alternating from the wrong end. Start the alternating sum at the units digit with a plus sign.
  • Stopping at a yes or a no. The digit sum gives the remainder on division by 999. Use it.
  • Joining rules for divisors that share a factor. A number divisible by 666 and by 999 need not be divisible by 545454: think of 181818.

Remember these

  • a−b∣an−bna - b \mid a^n - b^na−b∣an−bn, and a+b∣an+bna + b \mid a^n + b^na+b∣an+bn when nnn is odd.
  • NNN and its digit sum leave the same remainder on division by 999 and by 333.
  • NNN and its alternating sum leave the same remainder on division by 111111.
  • The last kkk digits decide divisibility by 2k2^k2k and by 5k5^k5k.
  • 1001=7×11×131001 = 7 \times 11 \times 131001=7×11×13 gives a rule for all three.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. What remainder does 8 724 0158\,724\,0158724015 leave on division by 999?
  1. Is 918082918082918082 divisible by 111111?
  1. Prove that 7∣23n−17 \mid 2^{3n} - 17∣23n−1 for every whole number n≥1n \ge 1n≥1.
  1. Find the digit yyy for which 5274y‾\overline{5274y}5274y​ is divisible by 888.
  1. A six-digit number has the form abcabc‾\overline{abcabc}abcabc. Explain why it is divisible by 131313.

References

  • David M. Burton, Elementary Number Theory, Chapter 4, section 4.3 on special divisibility tests.
  • Ivan Niven, Herbert S. Zuckerman and Hugh L. Montgomery, An Introduction to the Theory of Numbers, Chapter 1 on divisibility.

Enroll free in Division, Divisibility Rules and Primes

Every lesson is open to read. Enrolling also lets you:

  • Mark lessons done and carry on where you stopped.
  • Take the tests of this lesson and its course.
  • Count the course towards the certificate for its chapter.
No payment. You can leave at any time.

Problems (3)

A label on a box of 72 equal packets shows the total mass in grams as a five-digit number 6a49b…Hard · High School (11–12) · by StemPy Lab
A six-digit number is called a repeater when its last three digits repeat its first three, like…Hard · High School (11–12) · by StemPy Lab
A machine can print only the digits 0 and 1…Advanced · High School (11–12) · by StemPy Lab
Next: lesson 3Primes and the fundamental theorem
← Division, Divisibility Rules and Primes
← The division algorithm and divisibilityPrimes and the fundamental theorem →

Discussion (0)

Log in to join the discussion.

Loading…

,
444
,
555
,
888
,
999
and
111111
, and that gives each rule. The rules for
333
and
999
use the digit sum, the rule for
111111
the alternating sum, and the rule for
777
,
111111
and
131313
uses
1001=7×11×131001 = 7 \times 11 \times 131001=7×11×13
.
about 25 min1 simulation1 practice question1 Python program5 questions to check yourself

This lesson is free to read. Enroll free to keep your place and take the tests.