By the end of this chapter you'll be able to…

  • 1Use gcd, Bezout and the Euclidean algorithm in proofs
  • 2Apply Fermat, Euler, Wilson and the order of an element
  • 3Combine congruences with the Chinese remainder theorem
  • 4Use Legendre's formula, LTE and the Diophantine toolkit
💡
Why this chapter matters in INMO (Mathematical Olympiad)
A number theory problem is solved by choosing the right tool: a factorisation, a modulus, an order argument or lifting the exponent. Knowing each tool's conditions turns an unfamiliar problem into a short proof.

Number Theory for Olympiads — IOQM, RMO and INMO

Weightage: Number theory is one of the four olympiad areas (with algebra, combinatorics and geometry) and routinely supplies one or two problems in every stage from the IOQM to the INMO. The tools below are short, but a problem is solved by choosing the right one, so each section ends with a worked example.

1. Divisibility and the Euclidean algorithm

Write when for an integer . The greatest common divisor satisfies , which is the Euclidean algorithm. Its reverse gives Bezout's identity: integers exist with .

Two consequences recur constantly:

  • and imply .
  • has an integer solution exactly when .

Also , and .

2. Modular arithmetic

Congruence means , and it respects addition, multiplication and powers. Division needs care: you may cancel a factor only if .

Squares are restricted. A square is or , or , and or . A cube is . These facts kill many equations at once.

Worked example. The last two digits of : since and , we get , so the last two digits are .

3. Fermat, Euler and Wilson

For a prime and :

Euler's theorem generalises it: if then , where

Wilson's theorem: for a prime .

The order of modulo is the smallest with , and it divides . Whenever , the order divides . This single fact solves most "find the smallest exponent" questions.

Worked example. Prove . Factor as . It is even (consecutive integers), divisible by 3 (three consecutive integers), and by 5 because by Fermat. Since 2, 3 and 5 are coprime, divides it.

4. The Chinese remainder theorem

If the moduli are pairwise coprime, the system has a unique solution modulo .

Worked example. Solve , , . From the first and third, , so . Testing : . So .

CRT also lets you prove statements prime by prime and combine them.

5. Valuations and lifting the exponent

Let be the exponent of the prime in . Legendre's formula gives:

The lifting the exponent (LTE) lemma: for an odd prime with and ,

For with even, .

Worked example. Find . Here , so the lemma gives . For the answer is 3.

6. Diophantine equations: the toolkit

Try these in order.

  1. Factor. becomes . The positive pairs give .
  2. Parity and residues. Reduce modulo a small number to show there is no solution, such as .
  3. Bounding. Show the sides are close for large variables, then check the few remaining cases.
  4. Descent and Vieta jumping. For with positive integers, assume a minimal pair , treat the equation as a quadratic in , and replace by its other root . Minimality forces eventually, and that makes a perfect square.

Pythagorean triples are all of the form up to scaling, with coprime and of opposite parity.

7. Number theory in the IOQM

The IOQM asks for integer answers from 00 to 99, so these problems often end with a reduction modulo 100 or a count. Work out the structure, then compute carefully. In a count, test small cases first to confirm the pattern before generalising.

Common traps

  • Cancelling a factor that shares a divisor with the modulus. gives only.
  • Applying Euler's theorem when .
  • Using LTE without the condition .
  • Concluding from small cases. A pattern for is not a proof.
  • Forgetting negative factor pairs in a factoring argument.

Memory aids

  • "Order divides every exponent that gives 1": the order lemma.
  • "Factor, reduce, bound, descend": the Diophantine checklist.
  • "Squares: 0 or 1 mod 4": the most used residue fact.

Summary

Number theory rests on divisibility and gcd, congruences with Fermat and Euler, CRT for combining moduli, valuations with Legendre and LTE, and a Diophantine toolkit.

The skill is selection: look at the equation, pick the modulus or factorisation that exposes its structure, and prove every case.

Exam protocol

  • Test small values to guess the structure before proving.
  • State which theorem you use and check its conditions.
  • Handle negative integers and zero explicitly.
  • In the IOQM, double-check the final reduction modulo 100.

Key formulas & results

Everything to memorise for the exam hall, in one card. Screenshot this for revision.

Fermat's little theorem
Prime p not dividing a.
Euler's theorem
Requires gcd(a, n) = 1.
Lifting the exponent
v_p(x^n - y^n) = v_p(x-y) + v_p(n)
Odd prime p dividing x minus y and not dividing xy.
Legendre's formula
Exponent of p in a factorial.
⚠️

Traps INMO (Mathematical Olympiad) sets — and how to dodge them

These are the exact option-traps and misreads that cost marks under negative marking.

WATCH OUT
✗ Cancelling a factor that shares a divisor with the modulus.
✓ Cancel c only if gcd(c, n) = 1, otherwise reduce the modulus.
WATCH OUT
✗ Applying Euler's theorem when a and n share a factor.
✓ Check gcd(a, n) = 1 first.
WATCH OUT
✗ Using LTE without the condition that p does not divide xy.
✓ State and verify every hypothesis.
WATCH OUT
✗ Treating a pattern in small cases as a proof.
✓ Prove the general statement.
WATCH OUT
✗ Forgetting negative factor pairs.
✓ List all signed factorisations.

Exam-pattern practice

PYQ-style questions with full solutions. Work through them as a readiness check — mark yourself honestly and get your gap report at the end.

Readiness check

Are you exam-ready for Number Theory for Olympiads?

8 problems from this chapter. Try each one, reveal the worked solution, mark yourself honestly — get your gap report at the end.

8 questions~6 min

5-minute revision

The whole chapter, distilled. Read this the night before the exam.

  • •gcd via Euclid; Bezout: ax + by = gcd; gcd times lcm equals ab.
  • •Squares mod 4: 0 or 1; mod 8: 0, 1, 4; cubes mod 9: 0, 1, 8.
  • •Fermat a^(p-1) = 1 mod p; Euler needs gcd 1; Wilson (p-1)! = -1 mod p.
  • •Order divides phi(n) and every exponent that gives 1.
  • •CRT for pairwise coprime moduli gives a unique class modulo the product.
  • •LTE for odd p dividing x - y and not xy; Legendre for factorials.
  • •Diophantine order: factor, reduce, bound, descend.

INMO (Mathematical Olympiad) question blueprint

How this topic is asked, tier by tier — so you can prep to the pattern.

Typical weightage: 30

Question styleMarks eachTypical countWhat it tests
Modular arithmetic~2-4 marks in a typical paper
Squares~2-4 marks in a typical paper
Proof~4-6 marks in a typical paper
CRT~4-6 marks in a typical paper
Diophantine~4-6 marks in a typical paper
LTE~6-8 marks in a typical paper
Order~6-8 marks in a typical paper
Valuation~2-4 marks in a typical paper
Prep strategy
  • Small cases first
  • Verify theorem conditions
  • Handle zero and negatives

Exam-hall strategy

Battle-tested tips from mentors and toppers for this topic under the sectional clock.

  1. Test small cases before proving.
  2. State the theorem and verify its conditions.
  3. Handle zero and negatives explicitly.

Beyond the exam

Where this skill shows up in the job you're competing for — and in life.

Cryptography

RSA depends on Euler's theorem and the difficulty of factoring.

Error-detecting codes

Check digits and hash functions use modular arithmetic.

Where else this topic is tested

Prepare once, score in every exam that asks it.

IOQMInteger-answer number theory and counting problems
RMO and INMOProof-based number theory problems

Questions aspirants ask

Pulled from the Q&A community and mentor sessions.

The modular arithmetic, divisibility and counting tools here cover most IOQM number-theory items; the RMO and INMO add proof-writing.

Rarely. Learn Euler's criterion and the residue facts first.
Header Logo