A Level Further Mathematics · Chapter 36 · Further Pure Mathematics · Further Pure 2
Whole numbers hide a deep structure, and a few simple tools reveal it: remainders, highest common factors and careful counting.
Number theory studies the integers: how they divide one another, what remainders they leave and how they can be arranged and counted. This chapter builds the main tools, from Euclid's ancient algorithm to Fermat's little theorem, and finishes with the counting methods used throughout probability and computer science.
In this chapter · jump to a section
Start here
Your route through this chapter
By the end of this chapter you will be able to:
- use Euclid's algorithm to find the highest common factor of two integers
- use Bézout's identity to write the highest common factor as a combination of the two numbers
- work with congruences and find inverses modulo
- solve linear congruences, finding every solution
- use Fermat's little theorem to reduce large powers
- prove and use divisibility tests
- count arrangements, selections and derangements
Time: three sessions, about 4½ hours, plus the practice ladder and the exam workshop.
You need first: factors, multiples and primes, proof by induction, and the basic ideas of groups from earlier chapters.
The big idea
The big idea
Every integer can be divided by a positive integer to leave a remainder between and :
Much of number theory comes from studying these remainders. Two numbers with the same remainder behave alike in many calculations, so we can replace large numbers by small ones.
The chapter uses three ideas again and again. The highest common factor measures how much two numbers share. Congruences let us calculate with remainders. Counting arguments tell us how many ways something can happen. Together they solve problems that look impossible by direct calculation.
Why number theory matters
For centuries number theory was studied purely for its beauty. Today it secures almost every online payment and message. Public-key cryptography relies on the facts in this chapter: modular powers are easy to compute, but undoing them is extremely hard without a secret key. Fermat's little theorem and Euclid's algorithm sit at the heart of the systems that protect bank cards and websites.
Proof in number theory
Number theory is full of statements that are easy to test but hard to prove. Checking a claim for many numbers is never enough, because a counterexample might appear later. So this chapter relies heavily on proof. You will use direct algebraic proof, proof by induction and arguments with congruences. Writing these proofs clearly is a skill examiners reward highly.
The language of divisibility
We write , read as d divides n, when is a whole-number multiple of . A prime is an integer greater than one whose only positive divisors are one and itself. Every integer greater than one can be written as a product of primes in exactly one way, apart from the order. This fact, the fundamental theorem of arithmetic, underpins much of what follows.
Section 1
Euclid's algorithm
Highest common factors
The highest common factor of and , written or , is the largest integer dividing both. For small numbers we can find it from prime factorisations. For large numbers, factorising is slow, and Euclid's algorithm is far quicker.
The algorithm
Divide the larger number by the smaller to get a remainder. Then divide the smaller number by that remainder, and keep going. Each line has the form . The process stops when the remainder is zero. The last non-zero remainder is the highest common factor.
Common mistake: stopping the algorithm one step too early. The answer is the last non-zero remainder, which is the divisor in the final line. Reporting a remainder from an earlier line gives a number that does not yet divide the one before it.
Euclid's algorithm: tiling a rectangle with squares
- Step 1
- 1071 = 2 × 462 + 147
- Highest common factor
- not finished
Figure 36.1 tiles a rectangle with squares, one round of squares for each line of the algorithm. The wrong model's square from a line too early does not tile the rectangle exactly.
Why it works
Derivation: why each step keeps the highest common factor
If , any common divisor of and also divides . Conversely, any common divisor of and divides .
So the pairs share exactly the same common divisors, and in particular the same highest one.
The remainders strictly decrease, so the process must end, and when the remainder is zero, the highest common factor of the last divisor and zero is that divisor.
How fast it is
Euclid's algorithm is remarkably quick. The remainders shrink at least by half every two steps. So even for numbers with hundreds of digits, the algorithm finishes in a few hundred steps. This speed is why computers use it constantly, for example when simplifying fractions or setting up secure connections.
Lowest common multiples
Once you know the highest common factor, the lowest common multiple follows at once. The product of two positive integers equals the product of their highest common factor and their lowest common multiple. So the lowest common multiple is the product divided by the highest common factor. This avoids listing multiples, which is slow for large numbers.
Setting out the algorithm
Write each line of the algorithm on a new row, in the same form every time. Line up the dividend, the quotient, the divisor and the remainder. This layout makes back-substitution much easier later, because every number you need is in plain view. It also lets an examiner follow your method and award marks even if an arithmetic slip creeps in. A tidy table is worth the few extra seconds.
Euclid's original idea
Euclid described this method in his Elements more than two thousand years ago. He thought of it geometrically, as repeatedly subtracting the shorter of two lengths from the longer. The common measure he found is the longest length that fits exactly into both. The tiling in Figure 36.1 is the same idea. It is one of the oldest algorithms still in everyday use.
Worked example 1: a three-step algorithm
Use Euclid's algorithm to find .
| Working | Reason |
|---|---|
| Divide the larger number by the smaller one | |
| Divide the previous divisor by the remainder | |
| , so the answer is 21 | The last non-zero remainder is the answer |
Coprime pairs in the algorithm
When the algorithm ends with a remainder of one, the two numbers are coprime. Consecutive integers are always coprime, as are consecutive Fibonacci numbers. In fact, consecutive Fibonacci numbers make the algorithm run as slowly as possible for numbers of their size. Every quotient is then one, so the remainders shrink as slowly as they can. This curious fact links number theory to sequences.
Worked example 2: factor and multiple
Find and the lowest common multiple of 240 and 46.
| Working | Reason |
|---|---|
| , | Begin the algorithm with the two numbers |
| , , | Continue until the remainder is zero |
| hcf is 2, so the lowest common multiple is | Use the product of the two numbers |
Check yourself. Use Euclid's algorithm to find .
Show the answer
The lines are , then , then . The last non-zero remainder is 6, so the highest common factor of 84 and 30 is 6.
Using prime factorisations instead
For small numbers, prime factorisations give the highest common factor directly. Take each prime that appears in both numbers, using the smaller power each time. The lowest common multiple uses the larger power of every prime instead. However, factorising large numbers is very slow. Euclid's algorithm never needs to factorise anything, which is why it is preferred for large numbers.
Section 2
Bézout's identity
The identity
For any integers and , not both zero, there are integers and with
This is Bézout's identity. The integers and can be found by running Euclid's algorithm backwards, a process called back-substitution.
Back-substitution
Start from the line that gives the highest common factor as a remainder. Write that remainder as the dividend minus a multiple of the divisor. Then replace the divisor using the line above, and simplify. Keep going until only the two original numbers appear. Collect the coefficients carefully at each stage.
Common mistake: losing track of signs in back-substitution. Each substitution introduces a subtraction, and the signs alternate. A single sign error gives a pair that does not satisfy the identity. Always check the final pair by multiplying out.
Many solutions
Once one pair is found, there are infinitely many others. Adding a multiple of to and subtracting the same multiple of from keeps the total unchanged, where is the highest common factor. So the integer solutions lie at equal spacing along a straight line. Questions sometimes ask for the solution with the smallest positive .
Coprime numbers
Two integers are coprime when their highest common factor is one. Bézout's identity then gives . This is the key to finding inverses in modular arithmetic, as section 3 shows. It also proves that if a prime divides a product, it must divide one of the factors, a fact used constantly in number theory.
Keeping the numbers visible
During back-substitution, treat the original numbers and the remainders as names rather than values. Do not multiply them out until the very end. Collect the coefficient of each name at every stage. This keeps the working short and avoids losing track. Only at the end do you check the result by multiplying out, which confirms the whole calculation in one step.
Why the identity matters
Bézout's identity is more than a computational trick. It shows that the highest common factor is the smallest positive number that can be built from the two numbers by adding and subtracting multiples. Every other such combination is a multiple of it. This idea reappears in algebra, where it describes the structure of ideals in rings of polynomials.
Worked example 3: back-substitution
Find integers and with .
| Working | Reason |
|---|---|
| Start from the last useful line and substitute for 4 | |
| Substitute for 6 using the second line | |
| , so , | Substitute for 10 using the first line |
Diophantine equations
An equation where only integer solutions are wanted is called a Diophantine equation, after Diophantus of Alexandria. The linear equation with two unknowns has integer solutions exactly when the highest common factor of the coefficients divides the constant. If it does, scale a Bézout pair to fit. If it does not, there are no integer solutions, however hard you search.
Worked example 4: the general solution
Find all integer solutions of .
| Working | Reason |
|---|---|
| , | Run Euclid's algorithm on 17 and 5 |
| Back-substitute to reach the original numbers | |
| , for any integer | Shift along the line by the spacing |
Check yourself. Find integers and with .
Show the answer
Euclid's algorithm gives the remainders 13, 8, 5, 3, 2 and 1, and back-substitution through all six lines gives and . Checking, .
Section 3
Modular arithmetic
Congruences
We write , read as a is congruent to b modulo n, when divides . Equivalently, and leave the same remainder on division by . Congruences can be added, subtracted and multiplied just like equations. If and , then and .
Reducing large powers
To find a power modulo , reduce at every step rather than computing the full power. Look for a small power that is congruent to 1 or to , then use it to break the exponent down. For example, since , any power of 2 modulo 7 depends only on the exponent's remainder on division by 3.
Common mistake: dividing both sides of a congruence by a number that shares a factor with the modulus. Division is not always allowed. For example, , but 2 is not congruent to 7. Cancelling is safe only when the number is coprime to the modulus.
Inverses
An inverse of modulo is a number with . It exists exactly when and are coprime. To find it, use Bézout's identity: if , then , so is the inverse. For small moduli, trying each value in turn is also acceptable.
The integers modulo n as a group
The remainders coprime to form a group under multiplication modulo . Closure holds because a product of numbers coprime to is coprime to . Inverses exist by Bézout's identity. This links number theory to the group theory you met earlier. When is prime, every non-zero remainder has an inverse, so the group has elements.
Negative remainders
It is sometimes convenient to use negative remainders. For example, 6 is congruent to minus one modulo 7, which makes powers of 6 easy. Its even powers are congruent to one and its odd powers to minus one. At the end, convert any negative remainder to the usual range by adding the modulus. This trick often halves the work in power calculations.
Why congruences can be multiplied
If two numbers differ by a multiple of the modulus, and two others do too, their products also differ by a multiple of the modulus. Expanding the products shows this directly. This is why we can reduce at every stage of a long calculation. It is the key reason modular arithmetic is so efficient, and why computers can handle enormous powers quickly.
Worked example 5: a large power
Find the remainder when is divided by 7.
| Working | Reason |
|---|---|
| Find a small power congruent to one | |
| Split the exponent using the cycle length | |
| , so the remainder is 4 | Replace the cube by one |
Inverses by trial
For small moduli, an inverse can be found by trial. Multiply the number by 1, 2, 3 and so on until the product is one more than a multiple of the modulus. This is often quicker than Euclid's algorithm for moduli below about twenty. For larger moduli, trial becomes slow, and the systematic method is better. Exam questions that say use Euclid's algorithm require the systematic method.
Worked example 6: an inverse by Bézout
Find the inverse of 7 modulo 26.
| Working | Reason |
|---|---|
| , , | Run Euclid's algorithm on 26 and 7 |
| Back-substitute to reach 26 and 7 | |
| , so the inverse is | Reduce the coefficient into the range |
Check yourself. Find the inverse of 3 modulo 11.
Show the answer
Trying small multiples, , so . The inverse of 3 modulo 11 is therefore 4, and it exists because 3 and 11 are coprime.
Order of an element
The order of a number modulo n is the smallest positive power that is congruent to one. For example, the order of two modulo seven is three. Orders always divide the size of the group of invertible remainders. Knowing the order lets you reduce exponents even further than Fermat's little theorem allows, which can make calculations shorter.
Section 4
Linear congruences
Solving ax ≡ b (mod n)
Let . If does not divide , the congruence has no solutions. If divides , divide , and by . The new coefficient is coprime to the new modulus, so it has an inverse. This gives one solution modulo , which corresponds to exactly solutions modulo .
Common mistake: giving only one solution when there are several. When is greater than one, the solution modulo stands for different solutions modulo . List all of them, spaced apart, between 0 and .
Solutions of a linear congruence
- hcf(a, n)
- 2
- Does it divide b?
- yes
- Solutions
- 4, 9
Figure 36.3 plots for every and marks the solutions. The wrong model keeps only the first one, missing the rest.
The case of a prime modulus
When the modulus is prime, every coefficient that is not a multiple of the modulus is coprime to it. So the congruence always has exactly one solution. This makes arithmetic modulo a prime especially tidy. It behaves much like ordinary arithmetic with fractions, which is why primes are used for so many applications.
Checking solutions
Always substitute each solution back into the original congruence. Multiply, reduce modulo , and compare with . This takes seconds and catches errors in the inverse. When there are several solutions, checking one of them and confirming the spacing is usually enough. It is also wise to confirm that no other value works, by thinking about the highest common factor.
Systems of congruences
Sometimes a number must satisfy two congruences with different moduli at once. When the moduli are coprime, there is exactly one solution modulo their product. This is the Chinese remainder theorem. To find the solution, write the first congruence as an equation with a parameter, then substitute into the second. This method appears in puzzles about remainders and in calendar calculations.
Rewriting a congruence as an equation
A congruence can always be rewritten as an ordinary equation with an extra unknown. Saying that one number is congruent to another modulo n means their difference is n times some integer. This rewriting connects linear congruences to the Diophantine equations of section 2. Both are solved with Bézout's identity, which is why the two topics fit together so naturally.
Worked example 7: a unique solution
Solve .
| Working | Reason |
|---|---|
| , so there is exactly one solution | The coefficient is coprime to the modulus |
| Multiply both sides by the inverse 15 | |
| ; check | Reduce and substitute back to check |
Why there are exactly d solutions
After dividing through, the congruence has one solution modulo the smaller modulus. Moving back to the original modulus, that one solution splits into several, spaced evenly. Adding the smaller modulus repeatedly gives new values until you return to the start. There are exactly as many as the highest common factor, because that is how many times the smaller modulus fits into the larger one.
Worked example 8: two solutions
Solve .
| Working | Reason |
|---|---|
| , which divides 4 | Decide whether solutions exist and how many |
| , so | Divide through by two and use the inverse of 3 |
| or | List both values below ten, five apart |
Check yourself. Solve .
Show the answer
The highest common factor of 4 and 10 is 2, which divides 2, so there are two solutions. Dividing through gives , so , giving or .
Practical uses of congruences
Congruences appear in everyday checks. The final digit of a book's identification number is chosen so that a weighted sum of all the digits is a multiple of eleven. If a digit is copied wrongly, the check fails. Bank account numbers and barcodes use similar ideas. These check digits catch most typing errors immediately, and they rely entirely on modular arithmetic.
Section 5
Fermat's little theorem
The theorem
If is prime and is not a multiple of , then
Multiplying by gives the form , which holds for every integer . The theorem makes large powers modulo a prime easy, because the exponent can be reduced modulo .
Common mistake: applying Fermat's little theorem when the modulus is not prime. The theorem needs a prime modulus. For example, , not 1. Check that the modulus is prime before using the theorem.
Powers round a clock, and Fermat's little theorem
- Path
- 3 → 2 → 6 → 4 → 5 → 1
- 3^6 mod 7
- 1
- Order of a
- 6
- Modulus prime?
- yes, so the theorem applies
Figure 36.2 follows the powers of a number round a clock. For a prime modulus the path returns to 1 within steps, while the wrong model's claim fails for composite moduli.
Reducing exponents
To find , divide by and keep the remainder. Then , where is that remainder. This works because each block of factors of is congruent to 1. The method turns an enormous power into a small one.
Why the theorem is true
The proof workshop proves the theorem by comparing two products. Another proof uses groups. The non-zero remainders modulo a prime form a group of order . By Lagrange's theorem, the order of any element divides . So raising any element to the power gives the identity, which is 1.
Primality testing
Fermat's little theorem gives a quick test for whether a number might be prime. Pick a base and compute its power one less than the number, modulo the number. If the result is not 1, the number is certainly composite. If it is 1, the number is probably prime. Rare composite numbers, called Carmichael numbers, pass the test for every coprime base, so further tests are used in practice.
Small cases first
When a theorem seems abstract, test it on a small case before using it. Take the prime five and the base two. The powers of two modulo five run two, four, three and one, returning to one after four steps. That is exactly what the theorem predicts, since four is one less than five. Small checks like this build confidence and reveal misunderstandings early.
Worked example 9: a power modulo 7
Find the remainder when is divided by 7.
| Working | Reason |
|---|---|
| 7 is prime and does not divide 3, so | Check the conditions of Fermat's little theorem |
| , so | Reduce the exponent modulo six |
| , so the remainder is 4 | Compute the small power and reduce |
Fermat and public-key cryptography
Modern cryptography builds on a generalisation of Fermat's little theorem, due to Euler. A message is turned into a number and raised to a large power modulo a product of two huge primes. Anyone can perform this step. Undoing it requires knowing the two primes, which are kept secret. Factorising their product is believed to be practically impossible, which keeps the message safe.
Worked example 10: a power modulo 13
Find the remainder when is divided by 13.
| Working | Reason |
|---|---|
| 13 is prime, so | Apply Fermat's little theorem with p equal to 13 |
| , so | Reduce the exponent modulo twelve |
| , so the remainder is 3 | Reduce the result into the range |
Check yourself. Find the remainder when is divided by 11.
Show the answer
Since 11 is prime, , and , so . Squaring repeatedly, , and , so the remainder is 4.
Checking your reduction
When using Fermat's little theorem, it is easy to reduce the exponent modulo the wrong number. The exponent is reduced modulo one less than the prime, not modulo the prime itself. A quick check with a small power you can compute directly will catch this error. If the small case disagrees, look again at the exponent reduction.
Section 6
Divisibility tests
Tests for 3 and 9
Since , every power of 10 is congruent to 1 modulo 9. So a number is congruent to the sum of its digits modulo 9. A number is divisible by 9 exactly when its digit sum is. The same argument works modulo 3, since too.
Proof: the digit sum test for 9
Write the number in terms of its digits and use the congruence for each power of ten.
This holds because each power of ten is one more than a multiple of nine.
So N and its digit sum leave the same remainder on division by 9, and one is divisible by 9 exactly when the other is.
The test for 11
Since , the powers of 10 are alternately congruent to 1 and . So a number is congruent to its alternating digit sum, starting with a plus sign on the units digit. A number is divisible by 11 exactly when that alternating sum is.
Common mistake: using the ordinary digit sum to test divisibility by 11. The digit sum works for 3 and 9 only, because 10 is congruent to 1 for those moduli. For 11, the signs must alternate. The ordinary digit sum of 918082 is 28, but the number is divisible by 11.
A test for 7
There is no test for 7 as simple as those for 3, 9 and 11. One useful method removes the units digit and subtracts twice it from the number that remains. The result is divisible by 7 exactly when the original number is. Repeat until the number is small enough to check directly. The method works because .
Combining tests
To test divisibility by a composite number, test each coprime factor separately. For example, a number is divisible by 99 exactly when it is divisible by both 9 and 11. A number is divisible by 6 exactly when it is divisible by both 2 and 3. The factors must be coprime, so this trick does not work for 4 and 2 when testing for 8.
Casting out nines
Before calculators, accountants checked long additions and multiplications by casting out nines. They replaced each number by its digit sum modulo nine and repeated the calculation with these small numbers. If the results disagreed, there was certainly an error. The method misses some errors, such as swapped digits, but it catches most slips quickly.
Digital roots
Repeatedly adding the digits of a number until a single digit remains gives its digital root. The digital root equals the remainder on division by nine, except that a multiple of nine gives nine rather than zero. Digital roots give a quick mental check on arithmetic. They also explain several number puzzles in which a hidden digit is revealed by a mysterious trick.
Worked example 11: the test for 9
Show that 7425 is divisible by 9, and hence by 3.
| Working | Reason |
|---|---|
| Add the digits of the number | |
| , so 9 divides 7425 | The digit sum is a multiple of nine |
| Since 3 divides 9, 3 also divides 7425 | Divisibility passes down to factors |
Tests for powers of two
Tests for powers of two look only at the final digits. A number is divisible by two when its last digit is even. It is divisible by four when its last two digits form a multiple of four, and by eight when its last three digits do. These work because a hundred is divisible by four and a thousand by eight. They complete the toolkit of divisibility tests.
Worked example 12: the test for 11
Show that 918082 is divisible by 11.
| Working | Reason |
|---|---|
| Form the alternating sum from the units digit | |
| The alternating sum is a multiple of eleven | |
| So 11 divides 918082 | The test for eleven confirms the claim |
Check yourself. Use the test for 7 to decide whether 3864 is divisible by 7.
Show the answer
Removing the units digit 4 and subtracting twice it gives . Repeating, , which is . So 3864 is divisible by 7, and indeed .
Proving a divisibility test
To prove a test, express the number in terms of its digits and powers of ten. Then reduce each power of ten modulo the divisor. If the powers follow a simple pattern, such as all being one or alternating in sign, the test follows at once. This approach can produce a test for any divisor, though some are too awkward to be useful.
Section 7
Counting
Permutations and combinations
The number of ways to arrange different items in a row is . The number of ordered selections of items from is . The number of unordered selections is . Decide first whether order matters, since that decides which formula to use.
Repeated items
When some items are identical, swapping them gives the same arrangement. So divide by the factorial of each group of repeats. The number of arrangements of items with groups of sizes is
Common mistake: forgetting to divide by the factorials of repeated items. Treating identical letters as different counts each arrangement many times over. For BANANA, the six letters give orders, but only different words.
Restrictions
Restrictions are handled by a few standard tricks. Items that must be together are glued into a single block, then the block is arranged internally. Items that must be apart are handled by arranging the others first and placing the restricted items in the gaps. For at least one of something, subtract the cases with none from the total.
Derangements
A derangement is an arrangement in which no item is in its original place. The number of derangements of items, , satisfies , with and . The first values are 0, 1, 2, 9, 44 and 265. The proportion of arrangements that are derangements approaches very quickly.
The multiplication principle
Most counting problems rest on one principle. If one choice can be made in m ways and a second in n ways, the pair can be made in m times n ways. Arrangements, selections and restrictions all follow from repeated use of this idea. When a problem seems confusing, break it into a sequence of choices and multiply the numbers of options.
Choosing the right method
Ask two questions before counting. First, does order matter? If so, count arrangements; if not, count selections. Second, are any items identical, or are there restrictions? Repeats lead to division by factorials, and restrictions lead to blocks, gaps or subtraction. Answering these questions first usually makes the correct formula obvious.
Worked example 13: repeated letters
How many different arrangements are there of the letters of MISSISSIPPI?
| Working | Reason |
|---|---|
| 11 letters: one M, four I, four S, two P | Count each group of identical letters |
| Divide by the factorial of each group | |
| Evaluate the factorials and simplify |
Why the derangement recurrence works
Consider where the first item goes in a derangement. It must go to one of the other places, in one of n minus one ways. Then either the displaced item swaps back into the first place, leaving a derangement of the rest, or it does not. Counting these two cases gives the recurrence. This kind of argument, splitting into cases, is typical of combinatorics.
Counting with complements
Some problems are easier to count from the other side. To count arrangements where at least one condition holds, count all arrangements and subtract those where none holds. This complement method avoids adding up many overlapping cases. It works especially well with phrases like at least one, which otherwise require a long list of separate cases.
Worked example 14: derangements of four
Four letters are placed at random in four addressed envelopes. In how many ways is no letter in the correct envelope?
| Working | Reason |
|---|---|
| , | Start the recurrence with the first values |
| Use the recurrence with n equal to three | |
| Use the recurrence again with n equal to four |
Check yourself. In how many ways can a committee of 3 be chosen from 10 people?
Show the answer
The order of the members does not matter, so this is a combination. The number is different committees.
Inclusion and exclusion
Derangements can also be counted by inclusion and exclusion. Start with all arrangements, subtract those that fix at least one item, add back those that fix two, and so on. The result is a sum of alternating terms, which matches the series for one over e. This explains why the proportion of derangements settles so quickly near that value.
Reference
Results in this chapter
| Result | What it says | When to use it | In the formula booklet? |
|---|---|---|---|
| Euclid's algorithm | Highest common factors | No, learn it | |
| Bézout's identity | Inverses and Diophantine equations | No, learn it | |
| Solvable exactly when hcf(a, n) divides b | Linear congruences | No, learn it | |
| Fermat's little theorem | Large powers modulo a prime | No, learn it | |
| Digit sums and alternating sums | Tests for 3, 9 and 11 | Divisibility | No, learn it |
| Arrangements with repeats | Counting words and patterns | No, learn it | |
| Derangements | Nothing in its own place | No, learn it |
Reasoning
Proof workshop: Fermat's little theorem
The claim
If is prime and is not a multiple of , then .
Strategy
Compare two lists of numbers modulo . The first list is . The second is . Show that the second list is just the first list in a different order. Then their products are congruent, and cancelling the common factor gives the result.
The key step is showing that the multiples of are all different modulo . That uses the fact that has an inverse modulo the prime . Cancelling the product at the end also needs each factor to be coprime to , which is true because is prime.
The proof
Suppose for some and between 1 and . Since is coprime to , it has an inverse, so , and hence . None of the multiples is congruent to 0 either. So the numbers are congruent, in some order, to . Multiplying each list together gives
Each factor of is coprime to , so has an inverse modulo . Multiplying by that inverse gives
Checking every step
The step that the multiples are distinct uses the inverse of , which exists because is prime and is not a multiple of . The step that no multiple is zero uses the same fact: if divided , it would divide or , and neither is possible.
A numerical check uses and . The multiples 3, 6, 9, 12, 15, 18 reduce to 3, 6, 2, 5, 1, 4, which is the list 1 to 6 in a new order. And , so , as the theorem predicts.
The proof also shows where it fails for a composite modulus. If the modulus shares a factor with , two multiples can coincide, the lists no longer match, and the argument breaks down.
Your turn
Prove that is divisible by 5 for every integer .
Show a model proof
By Fermat's little theorem in the form , with , we have for every integer . So 5 divides . This form includes the case where 5 divides , since both sides are then zero.
Practice
Practice ladder
Rung 1: Recall and fluency
Q1. Apply Euclid's algorithm to 252 and 198 to find their highest common factor.
Worked solution to Q1
The lines are , then , then , then . The last non-zero remainder is 18, so that is the highest common factor.
Q2. Calculate the remainder when is divided by 7.
Worked solution to Q2
Since , every block of three factors of 2 can be replaced by one. Writing , the power reduces to . So the remainder when is divided by 7 is 4, found without ever computing the full power.
Q3. Is 123456 divisible by 3? Explain how you know.
Worked solution to Q3
The digit sum is , which is a multiple of 3. A number is congruent to its digit sum modulo 3, so 123456 is divisible by 3.
Rung 2: Application
Q4. Express 18 in the form , where and are integers.
Worked solution to Q4
Back-substituting through the lines from Q1, . Replacing 54 by gives , so and . Multiplying out confirms the pair, since the two products differ by exactly 18.
Q5. Determine the inverse of 5 modulo 12.
Worked solution to Q5
Since 5 and 12 are coprime, an inverse exists. Trying multiples, , so 5 is its own inverse modulo 12.
Q6. Solve , giving every solution.
Worked solution to Q6
The highest common factor of 9 and 15 is 3, which divides 6, so there are three solutions. Dividing through gives , so , and the solutions are .
Rung 3: Analysis
Q7. Using your answer to the check-yourself in section 1, find the lowest common multiple of 84 and 30.
Worked solution to Q7
The highest common factor of 84 and 30 is 6. The product of two numbers equals their highest common factor times their lowest common multiple, so the lowest common multiple is .
Q8. What is the remainder when is divided by 11?
Worked solution to Q8
Since 11 is prime and does not divide 7, Fermat's little theorem gives . As , the power reduces to , so the remainder is 5.
Q9. Count the different arrangements of the letters of BANANA.
Worked solution to Q9
There are six letters, with three A, two N and one B. Dividing by the factorial of each group of repeats gives different arrangements.
Rung 4: Stretch
Q10. Six people each leave a coat at a cloakroom, and the coats are handed back at random. In how many ways does nobody receive their own coat?
Worked solution to Q10
This counts derangements of six items. Continuing the recurrence from , we get and then ways.
Q11. Show, using Fermat's little theorem, that is divisible by 7 for every integer , and verify it for .
Worked solution to Q11
Fermat's little theorem in the form with gives , so 7 divides . The form used includes the case where 7 divides , since both sides are then multiples of 7. For , and , as expected.
Q12. How many arrangements of MISSISSIPPI have all four S together?
Worked solution to Q12
Glue the four S into a single block, which leaves eight items: the block, one M, four I and two P. Dividing by the repeated letters gives arrangements, and the block itself has only one internal order.
Exam practice
Exam technique and worked answer workshop
How these questions are marked
M1 marks go to correct lines of Euclid's algorithm, back-substitution, reducing exponents, dividing through by the highest common factor and setting up counts. A1 marks go to correct highest common factors, Bézout pairs, remainders, solution sets and totals. B1 marks go to stating conditions, such as the modulus being prime.
Show every line of Euclid's algorithm, since each carries credit. When using Fermat's little theorem, state that the modulus is prime and that it does not divide the base. For linear congruences, list every solution in the range asked for.
Exam question 1 (5 marks · Paper 4 · about 6 minutes)
(a) Use Euclid's algorithm to find the highest common factor of 1071 and 462. (2)
(b) Hence find integers and with . (3)
Mark scheme for exam question 1
(a) Correct lines of the algorithm M1
Highest common factor 21 A1
(b) Back-substitutes from the second line M1
M1
, A1
Exam question 2 (6 marks · Paper 4 · about 8 minutes)
(a) By Euclid's algorithm, find the inverse of 7 modulo 26. (4)
(b) Hence solve . (2)
Mark scheme for exam question 2
(a) Euclid's algorithm on 26 and 7 M1
Back-substitution M1
A1
Inverse 15 A1
(b) M1
A1
Exam question 3 (6 marks · Paper 4 · about 8 minutes)
Find all the solutions of , explaining why there are exactly that many. (6)
Mark scheme for exam question 3
B1
2 divides 4, so two solutions B1
M1
Inverse of 3 modulo 5 is 2 M1
A1
or A1
Exam question 4 (6 marks · Paper 4 · about 8 minutes)
(a) Use Fermat's little theorem to find the remainder when is divided by 7. (3)
(b) Find the remainder when is divided by 13. (3)
Mark scheme for exam question 4
(a) 7 prime, so B1
M1
Remainder 4 A1
(b) B1
M1
Remainder 3 A1
Exam question 5 (6 marks · Paper 4 · about 8 minutes)
(a) Prove that is divisible by 5 for every integer . (4)
(b) Hence find the remainder when is divided by 5. (2)
Mark scheme for exam question 5
(a) Uses Fermat with M1
Case 5 does not divide n: M1
So A1
Case 5 divides n: both sides zero, so 5 divides for all n A1
(b) M1
Remainder 2 A1
Exam question 6 (6 marks · Paper 4 · about 8 minutes)
(a) Explain why a number is divisible by 11 exactly when its alternating digit sum is. (3)
(b) Hence show that 918082 is divisible by 11, and determine whether it is divisible by 9. (3)
Mark scheme for exam question 6
(a) M1
M1
So N is congruent to its alternating sum A1
(b) Alternating sum M1
Divisible by 11 A1
Digit sum 28, not a multiple of 9, so not divisible by 9 B1
Exam question 7 (6 marks · Paper 4 · about 8 minutes)
(a) Find the number of different arrangements of the letters of MISSISSIPPI. (3)
(b) Find how many of these arrangements have all four S together. (3)
Mark scheme for exam question 7
(a) Divides 11! by factorials of repeats M1
A1
34650 A1
(b) Treats the four S as one block M1
A1
840 A1
Exam question 8 (7 marks · Paper 4 · about 10 minutes)
Five letters are placed at random into five addressed envelopes, one in each.
(a) Show that the number of ways in which no letter is in its correct envelope is 44. (4)
(b) Find the probability that exactly one letter is in its correct envelope. (3)
Mark scheme for exam question 8
(a) Uses M1
A1
A1
A1
(b) M1
A1
A1
Annotated model answer: exam question 2
Euclid's algorithm gives , and . M1. Back-substituting, . M1 A1.
So , and the inverse is . A1. Multiplying by 15 gives . M1 A1. As a check, .
Annotated model answer: exam question 8
The recurrence starts from and . M1. Then and . A1 A1. Finally . A1.
For exactly one correct letter, choose which letter is correct in 5 ways, then derange the other four in ways, giving 45 arrangements. M1 A1. There are equally likely arrangements in all, so the probability is . A1.
Connections
Synoptic link
Groups, subgroups and Lagrange's theorem gives a second proof of Fermat's little theorem. The non-zero remainders modulo a prime form a group, and every element's order divides the group's order. Proof by induction supplies another route to results such as the divisibility of by 5.
Recurrence relations and sequences, the next chapter, studies recurrences like the one for derangements in general. Isomorphism and the structure of small groups uses the cyclic groups of remainders that appear in Figure 36.2.
Synoptic question 1. The group of non-zero remainders modulo 7 under multiplication has order 6. Use Lagrange's theorem to list the possible orders of its elements, and find the order of 2.
Answer to synoptic question 1
By Lagrange's theorem, the order of every element divides 6, so the possible orders are 1, 2, 3 and 6. Since , and , the order of 2 is 3.
Recap
Recap and next step
- Euclid's algorithm finds the highest common factor as the last non-zero remainder.
- Back-substitution gives Bézout's identity, , and hence inverses modulo .
- Congruences can be added and multiplied, but cancelling needs a factor coprime to the modulus.
- The congruence has solutions when divides , and none otherwise.
- Fermat's little theorem, , needs a prime modulus.
- Digit sums test for 3 and 9, and alternating sums test for 11.
- Arrangements with repeats divide by factorials, and derangements follow a recurrence.
Next chapter: Recurrence relations and sequences, where sequences defined step by step are solved to give closed formulae.
For your exam board
This chapter covers Pearson Edexcel A Level Further Mathematics (9FM0) Further Pure Mathematics 2 section 5: the division algorithm, Euclid's algorithm and Bézout's identity, modular arithmetic and congruences, Fermat's little theorem, divisibility tests, and combinatorics including derangements. It is assessed on Paper 4A, Further Pure Mathematics 2. Similar content appears in AQA (7367) and OCR (H245) further pure options.