Salam Academy
Contents · 0% complete
  1. Learning objectives
  2. Core idea
  3. Key formulae
  4. Worked examples
  5. Explore the graph
  6. Common mistakes
  7. Exam tip
  8. Guided practice
  9. Practice questions
  10. Challenge
  11. Summary
  12. Quick quiz
  13. Same topic, different board
  14. Past paper questions
Number theory · Subtopic 1 of 1

Number Theory

Euclid's algorithm finds gcd⁡(a,b)\gcd(a,b) by repeated division, and running it backwards writes the gcd as ax+byax+by (Bézout). In modular arithmetic we work with remainders: a≡b(modn)a\equiv b\pmod n means n∣a−bn\mid a-b. Fermat: for prime p∤ap\nmid a, ap−1≡1(modp)a^{p-1}\equiv1\pmod p.

Edexcel 9FM0 Option≈ 45 minRevision 1 · updated 2026-10-27
Section 1 of 14

Learning objectives

  • Use the Euclidean algorithm and Bézout's identity.
  • Calculate with congruences and solve linear congruences.
  • Use Fermat's little theorem for large powers.
  • Explain divisibility tests.
Pause and think

It's 9 o'clock. What time will it be in 100 hours?

Section 2 of 14

Core idea

Start hereClock arithmetic

If it's 9 o'clock now, what time is it in 100 hours? You don't need to count: only the remainder after dividing by 24 matters. Arithmetic with remainders turns huge calculations into small ones, and it secures every online payment.

The big idea

Euclid's algorithm finds gcd⁡(a,b)\gcd(a,b) by repeated division; reversing it writes gcd⁡(a,b)=ax+by\gcd(a,b)=ax+by. Congruences mod nn let us add and multiply remainders, and Fermat's little theorem cuts large powers down to size.

1. Euclid's algorithm and Bézout

Why gcd⁡(a,b)=gcd⁡(b,r)\gcd(a,b)=\gcd(b,r)
  1. a=qb+ra=qb+r
    Division algorithm, 0≤r<b0\le r<b.
  2. d∣a, d∣b⇒d∣a−qb=rd\mid a,\ d\mid b\Rightarrow d\mid a-qb=r
    A common divisor of a,ba,b divides rr.
  3. d∣b, d∣r⇒d∣qb+r=ad\mid b,\ d\mid r\Rightarrow d\mid qb+r=a
    And conversely.
Same common divisors, so same gcd. Repeat until the remainder is 00.
Worked examplegcd⁡(252,198)\gcd(252,198) and Bézout

Find gcd⁡(252,198)\gcd(252,198) and integers x,yx,y with 252x+198y=gcd⁡252x+198y=\gcd.

Goal
gcd and x,yx,y.
Strategy
Divide down, then substitute back up.
  1. 252=1⋅198+54252=1\cdot198+54
    First division.
  2. 198=3⋅54+36,54=1⋅36+18,36=2⋅18198=3\cdot54+36,\quad54=1\cdot36+18,\quad36=2\cdot18
    Continue until remainder 00.
  3. 18=54−3618=54-36
    Start from the last non-zero remainder.
  4. =54−(198−3⋅54)=4⋅54−198=54-(198-3\cdot54)=4\cdot54-198
    Replace 3636.
  5. =4(252−198)−198=4⋅252−5⋅198=4(252-198)-198=4\cdot252-5\cdot198
    Replace 5454.
Answergcd⁡=18=252(4)+198(−5)\gcd=18=252(4)+198(-5).
✓ Check1008−990=181008-990=18 ✓.

2. Congruences and Fermat

a≡b(modn)  ⟺  n∣a−ba\equiv b\pmod n\iff n\mid a-b
where
nn
the modulus.
Worked exampleSolving a linear congruence

Solve 3x≡4(mod7)3x\equiv4\pmod7.

Goal
xx mod 7.
Strategy
Multiply by the inverse of 3.
  1. 3×5=15≡13\times5=15\equiv1
    So 3−1≡5(mod7)3^{-1}\equiv5\pmod7.
  2. x≡5×4=20≡6x\equiv5\times4=20\equiv6
    Multiply both sides by 55.
Answerx≡6(mod7)x\equiv6\pmod7.
✓ Check3×6=18≡43\times6=18\equiv4 ✓.
Fermat's little theorem (idea)
  1. {a,2a,…,(p−1)a}≡{1,2,…,p−1}\{a,2a,\ldots,(p-1)a\}\equiv\{1,2,\ldots,p-1\}
    Multiplying by aa just reorders the non-zero remainders (pp prime, p∤ap\nmid a).
  2. ap−1(p−1)!≡(p−1)!a^{p-1}(p-1)!\equiv(p-1)!
    Multiply all elements of each set.
  3. ap−1≡1(modp)a^{p-1}\equiv1\pmod p
    (p−1)!(p-1)! is coprime to pp, so cancel.
Worked example2100 mod 72^{100}\bmod7

Find the remainder when 21002^{100} is divided by 77.

Goal
A remainder.
Strategy
Find a small power ≡1\equiv1.
  1. 23=8≡12^3=8\equiv1
    Even quicker than Fermat's 262^6.
  2. 2100=(23)33⋅22^{100}=(2^3)^{33}\cdot2
    100=3×33+1100=3\times33+1.
  3. ≡133⋅2=2\equiv1^{33}\cdot2=2
    Replace 232^3 by 11.
Answer22.
✓ CheckPowers cycle 2,4,12,4,1; position 100≡1(mod3)100\equiv1\pmod3 gives 22 ✓.
Divisibility tests come from congruences

Each test is just a congruence for 10.

Common misconceptionNo dividing From 6x≡6(mod9)6x\equiv6\pmod9 you can't cancel 6 to get x≡1x\equiv1: x=4x=4 and x=7x=7 also work, because gcd⁡(6,9)=3\gcd(6,9)=3.
TrickDivisible by 11 10≡−1(mod11)10\equiv-1\pmod{11}, so take alternate digit sums: 918082→2−8+0−8+1−9=−22918082\to2-8+0-8+1-9=-22, divisible by 11.
Pause and think

Find 512 mod 135^{12}\bmod13 without a calculator.

Summary

  • gcd⁡(a,b)=gcd⁡(b,r)\gcd(a,b)=\gcd(b,r).
  • Back-substitute for Bézout.
  • Solve congruences with inverses.
  • Fermat: ap−1≡1(modp)a^{p-1}\equiv1\pmod p.
Key words
Congruent
Same remainder on division by n.
Coprime
gcd equal to 1.
Modular inverse
bb with ab≡1(modn)ab\equiv1\pmod n.
HistoryEuclid and Fermat. Euclid's algorithm (c. 300 BC) is one of the oldest algorithms still in daily use. Fermat stated his "little theorem" in a 1640 letter, without proof.
Fun factRSA. Every secure website uses modular powers: RSA encryption relies on Fermat's (and Euler's) theorem.
Section 3 of 14

Key formulae

Division algorithma=qb+r, 0≤r<b;gcd⁡(a,b)=gcd⁡(b,r)a=qb+r,\ 0\le r<b;\quad\gcd(a,b)=\gcd(b,r)
Bézoutgcd⁡(a,b)=ax+by for some integers x,y\gcd(a,b)=ax+by\ \text{for some integers }x,y
Fermat's little theoremp prime, p∤a ⇒ ap−1≡1(modp)p\text{ prime},\ p\nmid a\ \Rightarrow\ a^{p-1}\equiv1\pmod p
TrickDivisibility by 9. 10≡1(mod9)10\equiv1\pmod9, so every power of 10 is ≡1\equiv1: a number is congruent to its digit sum mod 9 (and mod 3).
Section 4 of 14

Worked examples

Example 1 · Euclid and Bézout0 / 3 steps
Find gcd⁡(252,198)\gcd(252,198) and integers with 252x+198y=gcd⁡252x+198y=\gcd.
    Example 2 · A congruence0 / 2 steps
    Solve 3x≡4(mod7)3x\equiv4\pmod7.
      Section 5 of 14

      Explore the graph

      Powers of 2 mod 7 repeat
      Loading the interactive graph…
      Try this
      1. The remainders cycle 1,2,4,1,2,4,…1,2,4,1,2,4,\ldots with period 33.
      2. Fermat guarantees the period divides 7−1=67-1=6.

      23≡1(mod7)2^3\equiv1\pmod7.

      In the real worldISBN check digits. Book numbers end in a check digit chosen so a weighted sum is divisible by 11 (or 10): a single mistyped digit always breaks the congruence.
      Section 6 of 14

      Common mistakes

      IncorrectDividing in congruences
      CorrectMultiply by an inverse
      Division only works when the divisor is coprime to the modulus.
      IncorrectFermat for composite nn
      Correctnn must be prime
      28≢1(mod9)2^{8}\not\equiv1\pmod9.
      IncorrectLosing track in back-substitution
      CorrectKeep aa and bb as symbols
      Collect multiples of the original numbers at each step.

      2¹⁰⁰ mod 7 by calculator

      Fermat: 2³ ≡ 1, so it's 2. Next question.

      Section 7 of 14

      Exam tip

      Exam tipLayout for Euclid. Write each line as a=qb+ra=qb+r in a column; back-substitution is far easier when the lines are aligned.
      Section 8 of 14

      Guided practice

      SA-FP-NT-G011 markL1 FoundationNon-calculatorCongruences
      Find 47 mod 547\bmod5.

      Sign in or create a free account to check answers, get hints and track your progress.

      Salam Academy Original Practice · Proposed mark scheme
      Section 9 of 14

      Practice questions

      SA-FP-NT-0012 marksL2 StandardNon-calculatorEuclid
      Use the Euclidean algorithm to find gcd⁡(252,198)\gcd(252,198).

      Sign in or create a free account to check answers, get hints and track your progress.

      Salam Academy Original Practice · Proposed mark scheme
      SA-FP-NT-0022 marksL2 StandardNon-calculatorCongruences
      Solve 3x≡4(mod7)3x\equiv4\pmod7, giving 0≤x<70\le x<7.

      Sign in or create a free account to check answers, get hints and track your progress.

      Salam Academy Original Practice · Proposed mark scheme
      SA-FP-NT-0033 marksL3 ExamNon-calculatorFermat
      Find 2100 mod 72^{100}\bmod7.

      Sign in or create a free account to check answers, get hints and track your progress.

      Salam Academy Original Practice · Proposed mark scheme
      SA-FP-NT-0041 markL1 FoundationNon-calculatorFermat
      Find 4872 mod 94872\bmod9 using the digit sum.

      Sign in or create a free account to check answers, get hints and track your progress.

      Salam Academy Original Practice · Proposed mark scheme

      More questions on every skill in this subtopic are in the question bank under Practise.

      Section 10 of 14

      Challenge

      SA-FP-NT-0054 marksL4 ChallengingNon-calculatorEuclid
      Find the smallest positive integer xx for which there is an integer yy with 252x+198y=18252x+198y=18.

      Sign in or create a free account to check answers, get hints and track your progress.

      Salam Academy Original Practice · Proposed mark scheme
      Section 11 of 14

      Summary

      • Euclid: repeated division.
      • Bézout: back-substitute.
      • Congruences: multiply by inverses.
      • Fermat reduces powers.
      Section 12 of 14

      Quick quiz

      Q1 · SA-FP-NT-Q011 markL1 FoundationNon-calculatorCongruences
      a≡b(modn)a\equiv b\pmod n means
      Choose one option

      Sign in or create a free account to check answers, get hints and track your progress.

      Salam Academy Original Practice · Proposed mark scheme
      Section 13 of 14

      Same topic, different board

      Specification
      A level Further Mathematics 9FM0
      Where
      Further Pure 2 · Number theory
      Expected
      Division algorithm, Euclid's algorithm, Bézout's identity, modular arithmetic, linear congruences, Fermat's little theorem, divisibility tests; combinatorics including derangements.
      Calculator
      Permitted; show enough working to earn the method marks.
      Typical style
      Edexcel often opens with a routine part and builds to a "show that" or "prove" part.
      Open in
      9FM0 · Option
      Section 14 of 14

      Past paper questions

      No past paper questions are tagged to this subtopic yet. We add papers every week.

      Browse past papers

      Salam Academy original content · Content status: reviewed and published. Syllabus mapping: Pearson Edexcel 9FM0, First teaching 2017 (official specification).