A congruence compares integers by divisibility of their difference. Solving a congruence means finding every residue class that satisfies that relation, not simply one integer that happens to work.
This lesson develops the algebra behind modular arithmetic: when cancellation is allowed, when several classes solve an equation, and how two remainder conditions can be combined.
On this page
State the relation and its domain
For integers and a positive modulus ,
Congruence is reflexive, symmetric and transitive. For transitivity, if and , then , so .
These properties explain why each residue class is a coherent group of equivalent representatives. They do not turn congruence into ordinary equality. The modulus remains part of the statement.
Find a modular inverse when it exists
For , an inverse of modulo is an integer satisfying . It exists exactly when .
For and , Euclid’s algorithm gives
Back-substitution yields . Thus is an inverse of 7 modulo 26; its least non-negative representative is 15. Check: .
To solve , multiply by that inverse:
Every integer is a solution, and no other residue class is. The check confirms the representative.
Explain the greatest-common-factor condition
For , let . The congruence
has an integer solution exactly when . Necessity follows from : both and are divisible by , so must be too.
When , divide the corresponding integer equation by . This gives
When , the reduced coefficient and modulus are coprime, so an inverse solves the reduced congruence. If its solution is , it represents distinct classes modulo the original .
Handle the remaining case directly: if , then . Every integer solves the original congruence when , and none does otherwise. For example, permits all fourteen residue classes; permits none. There is no need to perform an inverse calculation modulo 1. This is the structure of linear congruence solutions.
Solve a congruence with several classes
Consider . The GCF is 2, and 2 divides 8. Divide all three entries, including the modulus:
The inverse of 3 modulo 7 is 5, so . In the range , this gives two representatives, 6 and 13:
Their products with 6 are 36 and 78; both leave remainder 8 modulo 14. By contrast, has no solution because every value of is even while 5 is odd.
Keep every solution class in the original modulus
Diagram explanation and exact data
The reduced equation is modulo 7. Its solutions are integers 6+7k; two of them lie between 0 and 13. Checking all fourteen residues confirms there are no other solutions.
| Residue x | Remainder of 6x modulo 14 | Solution? |
|---|---|---|
| 0 | 0 | No |
| 1 | 6 | No |
| 2 | 12 | No |
| 3 | 4 | No |
| 4 | 10 | No |
| 5 | 2 | No |
| 6 | 8 | Yes |
| 7 | 0 | No |
| 8 | 6 | No |
| 9 | 12 | No |
| 10 | 4 | No |
| 11 | 10 | No |
| 12 | 2 | No |
| 13 | 8 | Yes |
For a simpler cancellation warning, reduces to , not . The original residue classes are 1 and 4. Changing the modulus is what preserves the full solution set.
Combine two coprime remainder conditions
Solve
The first condition gives . Substitute into the second:
Multiplying by the inverse 2 of 3 modulo 5 gives . Write and substitute back:
Thus . The solution is unique modulo the product 15 because 3 and 5 are coprime. This is a two-modulus instance of the Chinese remainder theorem, not a claim that every pair of conditions is compatible.
Check compatibility for non-coprime moduli
The conditions and are compatible. Their first shared non-negative value is 9, and all solutions have the form . The combined repeat interval is the LCM 12.
The conditions and are incompatible: the first demands an odd integer and the second an even integer. In general, and are compatible exactly when is divisible by . When compatible, the solution class is unique modulo .
For the examples, the common divisor 2 tests whether the remainders have the same parity. A numerical answer should always be substituted into every original condition, not just the last transformed equation.
Practice questions
- Solve .
- Give every solution residue modulo 6 for .
- Find the least non-negative integer with remainder 1 modulo 3 and remainder 2 modulo 4.
Check your answers
- The inverse of 5 modulo 7 is 3, so .
- Divide by 2 to obtain , then . The original residues are 2 and 5 modulo 6.
- The value is 10. It satisfies both conditions, and the full class is .
Related topics
Use Greatest Common Factor for the Euclidean and Bézout calculations. Rational and Irrational Numbers connects divisibility and prime exponents to exact number classification.
