Solve Congruence Equations Calculator

Solve congruences with clear gcd logic and reliable steps. View every residue class and step. Download results for study, teaching, or practice work today.

Calculator Input

Example Data Table

Mode Input What it checks Expected result
Linear 14x ≡ 30 (mod 100) gcd condition and two residues x ≡ 45, 95 (mod 100)
Linear 6x ≡ 14 (mod 28) reduction by gcd x ≡ 7, 21 (mod 28)
Linear 10x ≡ 7 (mod 25) failed divisibility test no solution
System x ≡ 2 (mod 3), x ≡ 3 (mod 5), x ≡ 2 (mod 7) Chinese remainder combination x ≡ 23 (mod 105)
System x ≡ 2 (mod 6), x ≡ 8 (mod 9) non-coprime consistent system x ≡ 8 (mod 18)

Formula Used

For a linear congruence ax ≡ b (mod m), compute d = gcd(a, m). The equation has solutions only when d divides b.

When d divides b, reduce the equation to (a/d)x ≡ (b/d) (mod m/d). Then find the modular inverse of a/d under modulus m/d.

The base solution is x₀ ≡ (b/d)(a/d)-1 (mod m/d). The full list modulo m is x = x₀ + k(m/d), where k = 0, 1, ..., d - 1.

For a system, the calculator combines two congruences at a time. A pair is compatible when the remainder difference is divisible by the gcd of the two moduli.

How to Use This Calculator

  1. Select linear mode to solve ax ≡ b (mod m).
  2. Enter integer values for a, b, and a positive m.
  3. Use the optional candidate field to test one value of x.
  4. Set a representative range to list matching integers.
  5. Select system mode to solve many lines like x = 2 mod 3.
  6. Keep one system congruence on each line.
  7. Press Submit to show results above the form.
  8. Use CSV or PDF buttons to save the result table.

Understanding Congruence Equation Solving

A congruence equation compares numbers by their remainders. The expression ax ≡ b (mod m) asks for values of x that make ax and b leave the same remainder after division by m. This calculator checks that condition before listing any answer. That makes the result reliable and easy to audit.

Why the Gcd Matters

The greatest common divisor controls whether a linear congruence has solutions. Let d = gcd(a, m). A solution exists only when d divides b. When this condition fails, no integer can satisfy the equation. When it passes, the equation can be reduced by d. The reduced coefficient becomes invertible under the reduced modulus. That inverse gives a base solution.

Reading the Answer

Linear congruences can have more than one answer in the original modulus. If d solutions exist, they are separated by m divided by d. The calculator lists each least nonnegative residue. It also shows a compact solution class. You can use that class to generate more integers by adding or subtracting the modulus.

System Mode

System mode solves several statements like x ≡ r (mod n). It uses a generalized Chinese remainder method. The moduli do not need to be pairwise coprime. Each pair must still agree on shared factors. If two remainders conflict under a common divisor, the system has no solution. Otherwise, the combined modulus grows to the least common multiple.

Practical Uses

Congruence equations appear in cryptography, calendars, cyclic schedules, coding theory, and contest mathematics. They also help test divisibility patterns. A clear step report is useful because a small sign error can change the result. This page shows the gcd, reduction, inverse, and final residues. Exports help save your work for worksheets or lesson notes.

Accuracy Tips

Use a positive modulus. Negative coefficients are allowed. Large values may still work, but extremely large integers can exceed normal server limits. Check entered systems line by line. Keep one congruence per line. For linear mode, verify a candidate value to confirm that both sides share the same remainder.

Learning Benefit

Students see not only the final residue, but also why it works. Teachers can compare examples, spot invalid inputs, and demonstrate modular patterns without rewriting every calculation by hand.

FAQs

What does a congruence equation mean?

It means two expressions leave the same remainder when divided by a chosen modulus. For example, ax ≡ b (mod m) asks for x values where ax and b match under modulus m.

When does ax ≡ b (mod m) have a solution?

It has a solution when gcd(a, m) divides b. If that divisor does not divide b, no integer x can satisfy the congruence.

Why are there multiple answers sometimes?

When d = gcd(a, m) is greater than one, there can be d residue classes modulo m. Each class gives infinitely many integer solutions.

Can I use negative numbers?

Yes. The calculator accepts negative coefficients, right sides, remainders, and candidate values. It normalizes residues into least nonnegative form for clearer reading.

What format works for system mode?

Enter one congruence per line. A line such as x = 2 mod 3 works. The first integer is read as the remainder, and the second as the modulus.

Do system moduli need to be coprime?

No. The generalized method also supports non-coprime moduli. The remainders must agree under every shared divisor, or the system is inconsistent.

What does the representative range do?

It lists actual integer values inside your chosen interval. These values satisfy the same residue class, so they help connect modular answers to ordinary integers.

What is saved in CSV and PDF exports?

The export buttons save the main result table. They also include range results when available. The PDF includes a simple report for printing or sharing.

Related Calculators

Paver Sand Bedding Calculator (depth-based)Paver Edge Restraint Length & Cost CalculatorPaver Sealer Quantity & Cost CalculatorExcavation Hauling Loads Calculator (truck loads)Soil Disposal Fee CalculatorSite Leveling Cost CalculatorCompaction Passes Time & Cost CalculatorPlate Compactor Rental Cost CalculatorGravel Volume Calculator (yards/tons)Gravel Weight Calculator (by material type)

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.