A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Modular Arithmetic and Congruences

College Depth 77 in the knowledge graph ☐ I know this ☆ Set as goal
6topics build on this
368prerequisites beneath it
See this on the map →
Divisibility, Primes, and Fundamental Theorem of ArithmeticModular Arithmetic and Congruences→→Consistent HashingLinear Congruences and the Chinese Remainder Theorem
modular-arithmetic congruence modulus arithmetic-mod-n

Core Idea

a ≡ b (mod n) means n divides a − b. Congruences behave like equality: if a ≡ b and c ≡ d (mod n), then a + c ≡ b + d and ac ≡ bd (mod n). Modular arithmetic is arithmetic in ℤₙ = {0, 1, ..., n−1} with operations mod n.

How It's Best Learned

Compute modular arithmetic examples: 7 ≡ 2 (mod 5), so 7 + 3 ≡ 2 + 3 ≡ 0 (mod 5). Recognize that ℤₙ is a ring (closed under + and ×). Practice properties and solve congruences.

Common Misconceptions

a ≡ b (mod n) is not the same as a = b; it's a relation. Division in modular arithmetic requires multiplicative inverses, which don't always exist.

Explainer

You already know modular arithmetic as clock arithmetic: on a 12-hour clock, 10 + 4 = 2 because you wrap around at 12. The discrete math formalization gives this intuition a rigorous foundation. The congruence relation a ≡ b (mod n) is defined precisely: it holds if and only if n divides a − b. So 17 ≡ 2 (mod 5) because 5 divides 17 − 2 = 15. This is different from equality — 17 and 2 are different integers, but they are congruent modulo 5. Congruence is an equivalence relation: it is reflexive (a ≡ a), symmetric, and transitive. These three properties mean it carves the integers into equivalence classes, called residue classes: all integers that leave the same remainder when divided by n form one class.

The key algebraic fact is that congruences are compatible with addition and multiplication. If a ≡ b (mod n) and c ≡ d (mod n), then a + c ≡ b + d (mod n) and a · c ≡ b · d (mod n). This means you can reduce numbers at any point in a computation. To compute 47 · 83 (mod 5), note 47 ≡ 2 and 83 ≡ 3, so the product ≡ 2 · 3 = 6 ≡ 1 (mod 5). You never needed to compute 3,901. This reduction principle is what makes modular arithmetic so useful in cryptography and number theory — you can keep numbers small throughout long computations.

The set of residue classes {0, 1, 2, ..., n−1} under addition and multiplication mod n forms the ring ℤₙ. In ℤₙ, addition always works exactly as expected. Multiplication usually works. The tricky operation is division. Dividing by a in ℤₙ requires a multiplicative inverse: some element b such that a · b ≡ 1 (mod n). From your divisibility prerequisite, you know the key fact: a has a multiplicative inverse in ℤₙ if and only if gcd(a, n) = 1. So in ℤ₆, the element 2 has no inverse because gcd(2, 6) = 2 ≠ 1 — the equation 2x ≡ 1 (mod 6) has no solution. But in ℤ₇ (where 7 is prime), every nonzero element has an inverse because gcd(a, 7) = 1 for all a ≢ 0. When n is prime, ℤₙ is not just a ring but a field — division by nonzero elements always works.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Set Operations: Union, Intersection, and Complement → Proof by Cases → Proving by Cases and Exhaustion → Vacuous Truth and Trivial Cases → Proof by Cases (Proof by Exhaustion) → Mathematical Induction → Divisibility and Greatest Common Divisor → The Euclidean Algorithm → Modular Arithmetic and Congruences → Modular Arithmetic and Congruences

Longest path: 78 steps · 368 total prerequisite topics

Prerequisites (2)

Leads To (2)