Advanced Modular Arithmetic
Competition Math · AMC 10/12 LevelPreview
1. Introduction
Modular arithmetic is the art of doing arithmetic with remainders. Instead of tracking a giant number, you track only what it leaves behind when divided by some modulus . This is exactly the tool you need for the AMC/AIME staples: "what is the last digit of ?", "what is the remainder when is divided by ?", or "find the smallest number leaving remainder mod and mod ." Each of these is hopeless by brute force but immediate once you think in residues.
The power of the subject comes from three landmark theorems. Fermat's Little Theorem and its generalization Euler's theorem let you shrink astronomical exponents down to size. The Chinese Remainder Theorem (CRT) lets you stitch together information from several coprime moduli into a single answer. Together with the basic rules that congruences respect addition and multiplication, these handle essentially every contest problem about powers, last digits, and systems of remainders.
This article develops the full machinery carefully: the definition and laws of congruence, modular inverses and when division is legal, Fermat and Euler with the totient function, order of an element, and CRT with a reliable solving procedure. Worked contest examples of rising difficulty show each tool in action.
2. Core Concepts
Concept 1 — Congruence and Its Definition
We write to mean , i.e. and leave the same remainder upon division by . Equivalently, for some integer . The modulus is always a positive integer in contest problems.
Concept 2 — Laws of Congruence
Congruence behaves like equality under the operations that matter:
- If and , then .
- Under the same hypotheses, .
- Consequently for any positive integer .
These laws let you replace any number by its residue before computing, keeping every intermediate value small.
Concept 3 — Residue Classes
The integers split into residue classes modulo , represented by . Every integer is congruent to exactly one of these representatives. Working with residues is the whole point of modular arithmetic.
Concept 4 — Euler's Totient Function
Euler's totient counts how many integers from to are coprime to . If , then For a prime , ; for a prime power, . The function is multiplicative: when .
Concept 5 — Modular Inverses
When , the element has a modular inverse with . Division by modulo means multiplication by . Find inverses via the extended Euclidean algorithm, by testing, or via Fermat: for prime .
Concept 6 — When Cancellation Fails
You may cancel a factor from both sides of only if . If , cancellation is invalid and can produce wrong answers. The correct rule: .
Concept 7 — Fermat's Little Theorem
Fermat's Little Theorem. If is prime and , then Equivalently, for all integers , . Fermat collapses exponents modulo when .
Concept 8 — Euler's Theorem
Euler's Theorem. If , then Fermat is the special case . Euler collapses exponents modulo when .
Concept 9 — Order of an Element
The order of modulo , written , is the smallest positive integer with . The order always divides (and divides for prime ). Knowing the order gives the sharpest exponent reduction: .
Concept 10 — The Chinese Remainder Theorem
Chinese Remainder Theorem (CRT). If are pairwise coprime, the system has a unique solution modulo . CRT is the standard tool for last-digit problems (split mod and mod for mod ) and for recombining prime-power information.
Concept 11 — Last Digits as Modular Problems
The units digit of is . The last two digits are . The last three digits are . For composite moduli like , solve mod each coprime factor and recombine with CRT.
Concept 12 — Splitting Composite Moduli
When with , solve a congruence modulo by solving it modulo and modulo separately, then recombining with CRT. This is often easier than working modulo directly, especially for .
Continue reading with Premium
Upgrade to read the full article and unlock all Premium features.
Free
- Unlimited practice — all difficulties
- 3 hints / day
- Community solutions
- 2 timed mocks / month
Premium
- ✓Full article + all 57+ theory guides
- ✓Unlimited hints on practice problems
- ✓Unlimited timed mock exams & PDF worksheets