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

Linear Congruences and Solutions

College Depth 79 in the knowledge graph ☐ I know this ☆ Set as goal
1topic build on this
366prerequisites beneath it
See this on the map →
Divisibility and Greatest Common DivisorModular Arithmetic and Congruences+1 more→→Simultaneous Congruences and Chinese Remainder Theorem
number-theory modular-arithmetic congruences

Core Idea

A linear congruence ax ≡ b (mod n) has solutions if and only if gcd(a,n) divides b. When solutions exist, there are exactly gcd(a,n) distinct solutions modulo n. These can be found using the extended Euclidean algorithm.

Explainer

A linear congruence ax ≡ b (mod n) is the modular-arithmetic analog of the linear equation ax = b. From your prerequisite on modular arithmetic, you know that x ≡ y (mod n) means n divides (x - y). Substituting this definition, ax ≡ b (mod n) is exactly the same as asking: for what integer x does n divide (ax - b)? In other words, you are looking for integers x and k such that ax - b = kn, or equivalently ax - kn = b. This is a linear Diophantine equation in two unknowns, and from your study of divisibility and GCD, you know when such equations have solutions.

The solvability condition follows directly from Bezout's theorem, which you encountered with GCD. The equation ax - kn = b has integer solutions if and only if gcd(a, n) divides b. Intuitively: the set of all values that ax - kn can take (as x and k range over integers) is exactly the multiples of gcd(a, n). So b must be one of those multiples for a solution to exist. If gcd(a, n) = 1 — that is, if a and n are coprime — then the condition is automatically satisfied for any b, and there is a unique solution modulo n. This is the clean, familiar case: 3x ≡ 5 (mod 7) has exactly one solution mod 7 because gcd(3,7) = 1.

When a solution exists, finding it uses the extended Euclidean algorithm — an algorithm you have already studied for computing GCDs. The algorithm finds integers s and t such that as + nt = gcd(a, n). If gcd(a, n) divides b, say b = gcd(a, n) · m, then a(sm) + n(tm) = b, which means x = sm is a solution to ax ≡ b (mod n). From this one solution, all others are obtained by adding multiples of n / gcd(a, n): the full solution set is x ≡ x₀ (mod n/gcd(a,n)), generating exactly gcd(a, n) distinct residues modulo n.

Understanding linear congruences is the key to unlocking the Chinese Remainder Theorem (CRT), which solves systems of simultaneous congruences with different moduli. CRT is fundamental in computer science (fast arithmetic, cryptography) and number theory. It also leads directly to modular inverses: when gcd(a, n) = 1, the unique solution to ax ≡ 1 (mod n) is called the modular inverse of a, written a⁻¹ mod n — the modular analog of dividing by a. Every step from here relies on the solvability test and solution technique you are learning now.

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 → Divisor Functions and Multiplicative Functions → Multiplicative Inverses in Modular Arithmetic → Linear Congruences and Solutions

Longest path: 80 steps · 366 total prerequisite topics

Prerequisites (3)

Leads To (1)