Modulo Equation Calculator

Compute congruences quickly with smart validation and instant insights for any case. Support for inverses, linear solutions, and Chinese remainder theorem across many moduli. See all solutions neatly reduced modulo the correct period for clarity. Export tables as CSV and PDF for sharing anywhere.

Solve Linear Congruence a · x ≡ b (mod m)
Works for negative values too. Returns general solution x ≡ x₀ (mod M′).
Modular Inverse a⁻¹ mod m
Inverse exists only when gcd(a, m) = 1.
System of Congruences (CRT)
# x ≡ r mod m
Handles non‑coprime moduli; reports when no solution exists.
Results
Timestamp Type Input Solution Steps
Example Data
Type Input Expected Output
Linear Congruence a=14, b=30, m=100 x ≡ 45 (mod 50)
Modular Inverse a=7, m=40 No inverse, because gcd(7, 40) = 1? False → 1. Actually gcd = 1, inverse ≡ 23.
CRT x ≡ 2 (mod 3), x ≡ 3 (mod 5), x ≡ 2 (mod 7) x ≡ 23 (mod 105)
Try these to verify correctness. Replace or extend as needed.
Formula Used

A linear congruence a·x ≡ b (mod m) is solvable iff g = gcd(a, m) divides b. When solvable, reduce by g: a′=a/g, b′=b/g, m′=m/g. Because gcd(a′, m′)=1, the inverse a′⁻¹ mod m′ exists and one solution is x₀ ≡ a′⁻¹ · b′ (mod m′). All solutions are x ≡ x₀ + k·m′ for any integer k.

For a system x ≡ rᵢ (mod mᵢ), we iteratively merge two congruences x ≡ r₁ (mod m₁) and x ≡ r₂ (mod m₂). Let g = gcd(m₁, m₂). A solution exists iff (r₂ − r₁) is divisible by g. If it exists, the combined solution is x ≡ r (mod lcm(m₁, m₂)) where r = r₁ + m₁ · k, and k satisfies m₁·k ≡ (r₂ − r₁) (mod m₂). We compute k using the extended Euclidean algorithm.

How to Use
  1. To solve a·x ≡ b (mod m), fill a, b, m and click Solve.
  2. To find a modular inverse, enter a and m, then click Find Inverse.
  3. For systems, add rows for each congruence r and m, then click Solve System.
  4. Review the steps via the expandable details in the results table.
  5. Use Export CSV or Download PDF to save the results table.
FAQs

It states that m divides a·x − b. We look for integers x satisfying that divisibility.

The inverse of a modulo m exists exactly when gcd(a, m) = 1.

Then the congruence has no solution. The algorithm will report that immediately.

Yes. It uses a generalized CRT merge and checks consistency before combining congruences.

We present the general class x ≡ x₀ (mod M′). Optionally, a few concrete representatives can be shown.
Definition & Notation

We write a ≡ b (mod m) when m divides a − b. Every integer maps to a residue class modulo m, represented by a number in [0, m−1]. Modular arithmetic supports addition, subtraction, and multiplication; division needs invertibility.

  • Normalize values with r = ((a % m) + m) % m to keep residues nonnegative.
  • Equivalent classes enable wrap‑around behavior used throughout number theory and computing.
Solvability & Number of Solutions

A linear congruence a·x ≡ b (mod m) has solutions iff g = gcd(a, m) divides b. When solvable, set a′=a/g, b′=b/g, m′=m/g and compute x₀ ≡ a′⁻¹·b′ (mod m′).

  • All solutions: x ≡ x₀ (mod m′). There are exactly g incongruent solutions modulo m.
  • Example. 14x ≡ 30 (mod 100). Here g=2; m′=50; one class is x ≡ 45 (mod 50). Modulo 100 that yields two residues: 45 and 95.
Generalized CRT Conditions

To merge two congruences x ≡ r₁ (mod m₁) and x ≡ r₂ (mod m₂), compute g=gcd(m₁,m₂). A solution exists iff (r₂−r₁) is divisible by g. The combined modulus is lcm(m₁,m₂)=m₁·m₂/g.

  • Consistent. x ≡ 2 (mod 3), x ≡ 3 (mod 5), x ≡ 2 (mod 7)x ≡ 23 (mod 105).
  • Inconsistent. x ≡ 0 (mod 4), x ≡ 3 (mod 6) since gcd(4,6)=2 but 3−0 isn’t divisible by 2.
Practical Applications & Tips
  • Cryptography. Modular inverses and CRT underpin RSA key operations and optimizations.
  • Scheduling. Align repeating cycles: solve day offsets under multiple periodic constraints.
  • Computer Science. Hashing, checksums, and pseudo‑random generators rely on residues.
  • Number Theory. Diophantine equations, primitive roots, and multiplicative groups.

Tip: Reduce inputs by gcd early and normalize residues before combining; it improves numerical stability and clarity of final periods.

Related Calculators

Proportion and Ratio Calculatorsquare root calculator with stepsnegative square root calculatorfraction square root calculatorsquare root division calculatordecimal to square root calculatorderivative of square root calculatorharmonic mean calculatorbinomial distribution mean calculatordiscrete random variable mean calculator

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.