Definition
A linear congruence is a congruence of the form
ax≡b(modn),where a,b∈Z, n∈N, and x is the unknown integer.
This congruence means that
n∣(ax−b).Equivalently, there exists an integer y such that
ax−b=ny.Rearranging gives the linear Diophantine equation
ax−ny=b.Thus solving a linear congruence is closely related to solving a linear equation in two integer variables.
First Examples
Consider
3x≡1(mod7).Testing residues modulo 7, we find
3⋅5=15≡1(mod7).So
x≡5(mod7)is the solution.
Now consider
4x≡2(mod6).Testing residues modulo 6,
4⋅2=8≡2(mod6)and
4⋅5=20≡2(mod6).Thus there are two residue classes of solutions:
x≡2(mod6),x≡5(mod6).A linear congruence may therefore have no solution, one solution modulo n, or several solutions modulo n.
Solvability Criterion
The congruence
ax≡b(modn)has an integer solution if and only if
gcd(a,n)∣b.Let
d=gcd(a,n).If x is a solution, then
ax≡b(modn),so
ax−b=nyfor some integer y. Hence
b=ax−ny.Since d∣a and d∣n, it follows that
d∣b.Conversely, if d∣b, Bezout’s identity gives integers u,v such that
au+nv=d.Multiplying by b/d, we obtain
a(udb)+n(vdb)=b.Thus
a(udb)≡b(modn).So the congruence has a solution.
The Coprime Case
The simplest case occurs when
gcd(a,n)=1.Then the congruence
ax≡b(modn)has a unique solution modulo n.
Since gcd(a,n)=1, the integer a has a multiplicative inverse modulo n. Let this inverse be a−1. Multiplying both sides by a−1, we get
x≡a−1b(modn).For example, solve
5x≡3(mod11).Since
5⋅9=45≡1(mod11),the inverse of 5 modulo 11 is 9. Therefore
x≡9⋅3=27≡5(mod11).So the solution is
x≡5(mod11).The General Case
Let
d=gcd(a,n).If
d∤b,then
ax≡b(modn)has no solution.
If
d∣b,divide the congruence by d. Write
a=da′,b=db′,n=dn′.Then
da′x≡db′(moddn′).This is equivalent to
a′x≡b′(modn′).Now
gcd(a′,n′)=1,so the reduced congruence has a unique solution modulo n′. This gives d distinct solutions modulo n.
Example of the General Case
Solve
6x≡9(mod15).We compute
d=gcd(6,15)=3.Since
3∣9,solutions exist.
Divide by 3:
2x≡3(mod5).The inverse of 2 modulo 5 is 3, because
2⋅3=6≡1(mod5).Thus
x≡3⋅3=9≡4(mod5).Modulo 15, this gives three solutions:
x≡4,9,14(mod15).Indeed,
6⋅4=24≡9(mod15),6⋅9=54≡9(mod15),and
6⋅14=84≡9(mod15).Number of Solutions
For the congruence
ax≡b(modn),let
d=gcd(a,n).If d∤b, there are no solutions modulo n.
If d∣b, there are exactly d incongruent solutions modulo n.
These solutions are separated by
dn.If x0 is one solution to the reduced congruence modulo n/d, then the full set of solutions modulo n is
x≡x0+kdn(modn),k=0,1,…,d−1.Role in Number Theory
Linear congruences are the first equations of modular arithmetic. They connect divisibility, greatest common divisors, Bezout identities, and modular inverses.
They are used in solving Diophantine equations, constructing modular inverses, proving the Chinese remainder theorem, analyzing periodic sequences, and building cryptographic algorithms.
The key principle is simple: the congruence
ax≡b(modn)is solvable exactly when the common divisor structure of a and n is compatible with b.