Skip to content

Systems of Congruences

A system of congruences asks for an integer satisfying several congruence conditions simultaneously.

Several Congruences at Once

A system of congruences asks for an integer satisfying several congruence conditions simultaneously.

For example,

x2(mod3) x\equiv2\pmod3

and

x3(mod5) x\equiv3\pmod5

form a system. A solution is an integer xx that satisfies both congruences.

Testing small values, we find

82(mod3) 8\equiv2\pmod3

and

83(mod5). 8\equiv3\pmod5.

Thus

x=8 x=8

is one solution. Since congruence conditions repeat periodically, there are infinitely many integer solutions, but they usually form one or more residue classes modulo a larger modulus.

Compatible Conditions

Not every system of congruences has a solution.

Consider

x1(mod4) x\equiv1\pmod4

and

x2(mod6). x\equiv2\pmod6.

The first congruence says that xx is odd. The second says that xx is even. These conditions cannot both hold. Therefore the system has no solution.

The obstruction comes from the fact that the moduli 44 and 66 are not coprime. Since

gcd(4,6)=2, \gcd(4,6)=2,

the two congruences must agree modulo 22. But

1≢2(mod2). 1\not\equiv2\pmod2.

Thus the system is incompatible.

Two Congruences

Consider the system

xa(modm), x\equiv a\pmod m, xb(modn). x\equiv b\pmod n.

This system has a solution if and only if

ab(modgcd(m,n)). a\equiv b\pmod{\gcd(m,n)}.

Equivalently,

gcd(m,n)(ab). \gcd(m,n)\mid(a-b).

This condition is necessary because any solution xx satisfies

xa0(modm) x-a\equiv0\pmod m

and

xb0(modn). x-b\equiv0\pmod n.

Hence xax\equiv a modulo every divisor of mm, and xbx\equiv b modulo every divisor of nn. In particular, modulo gcd(m,n)\gcd(m,n), the two residues must agree.

It is also sufficient, as follows from the Euclidean algorithm.

Reduction to a Linear Congruence

To solve

xa(modm), x\equiv a\pmod m,

write

x=a+mk x=a+mk

for some integer kk.

Substitute this into the second congruence:

a+mkb(modn). a+mk\equiv b\pmod n.

Thus

mkba(modn). mk\equiv b-a\pmod n.

This is a linear congruence in kk. It is solvable exactly when

gcd(m,n)(ba). \gcd(m,n)\mid(b-a).

This recovers the compatibility condition.

Once kk is found, the value

x=a+mk x=a+mk

gives a solution to the original system.

Example with Coprime Moduli

Solve

x2(mod3), x\equiv2\pmod3, x3(mod5). x\equiv3\pmod5.

Write

x=2+3k. x=2+3k.

Substitute into the second congruence:

2+3k3(mod5). 2+3k\equiv3\pmod5.

Hence

3k1(mod5). 3k\equiv1\pmod5.

Since

312(mod5), 3^{-1}\equiv2\pmod5,

we get

k2(mod5). k\equiv2\pmod5.

Thus

k=2+5t. k=2+5t.

Therefore

x=2+3(2+5t)=8+15t. x=2+3(2+5t)=8+15t.

So the solution is

x8(mod15). x\equiv8\pmod{15}.

The modulus 1515 is the product 353\cdot5, since the original moduli are coprime.

Example with Non-Coprime Moduli

Solve

x3(mod6), x\equiv3\pmod6, x7(mod10). x\equiv7\pmod{10}.

We have

gcd(6,10)=2. \gcd(6,10)=2.

Since

37(mod2), 3\equiv7\pmod2,

the system is compatible.

Write

x=3+6k. x=3+6k.

Substitute:

3+6k7(mod10). 3+6k\equiv7\pmod{10}.

Thus

6k4(mod10). 6k\equiv4\pmod{10}.

Divide by

gcd(6,10)=2. \gcd(6,10)=2.

This gives

3k2(mod5). 3k\equiv2\pmod5.

Since

312(mod5), 3^{-1}\equiv2\pmod5,

we obtain

k4(mod5). k\equiv4\pmod5.

Therefore

x=3+6(4+5t)=27+30t. x=3+6(4+5t)=27+30t.

Thus

x27(mod30). x\equiv27\pmod{30}.

The combined modulus is

lcm(6,10)=30. \operatorname{lcm}(6,10)=30.

General Form of the Solution

If the system

xa(modm), x\equiv a\pmod m, xb(modn) x\equiv b\pmod n

has a solution, then all solutions form one residue class modulo

lcm(m,n). \operatorname{lcm}(m,n).

This means that if x0x_0 is one solution, then every solution is given by

xx0(modlcm(m,n)). x\equiv x_0\pmod{\operatorname{lcm}(m,n)}.

The least common multiple appears because it is the smallest positive period shared by both congruence conditions.

Several Congruences

For a system

xa1(modn1), x\equiv a_1\pmod{n_1}, xa2(modn2), x\equiv a_2\pmod{n_2}, \cdots xar(modnr), x\equiv a_r\pmod{n_r},

compatibility must hold pairwise:

aiaj(modgcd(ni,nj)) a_i\equiv a_j\pmod{\gcd(n_i,n_j)}

for all i,ji,j.

When the system is compatible, the solutions form one residue class modulo

lcm(n1,n2,,nr). \operatorname{lcm}(n_1,n_2,\ldots,n_r).

A practical way to solve such a system is to combine two congruences at a time.

Pairwise Coprime Moduli

The cleanest case occurs when the moduli are pairwise coprime:

gcd(ni,nj)=1 \gcd(n_i,n_j)=1

whenever

ij. i\ne j.

Then every system

xai(modni) x\equiv a_i\pmod{n_i}

has a unique solution modulo

N=n1n2nr. N=n_1n_2\cdots n_r.

This is the Chinese remainder theorem, which will be studied next.

Pairwise coprimality removes all compatibility obstructions because every pair of residues automatically agrees modulo 11.

Role in Number Theory

Systems of congruences allow several local arithmetic conditions to be imposed simultaneously.

They appear in divisibility problems, calendar calculations, periodic sequences, modular equations, cryptography, and algebraic number theory.

The central question is compatibility. When moduli overlap through common divisors, the residues must agree on that overlap. When the moduli are coprime, the conditions are independent and can always be combined into a single congruence.