Mod Congruence Calculator

Work smarter with a rigorous modular arithmetic toolkit today. Check congruence, compute residues, and find modular inverses fast. Solve ax≡b mod n with stepwise, explainable methods clearly. Support CRT, gcd workflows, coprimality checks, and proofs. Export CSV, download PDF, share insights with your team.

Solves a·x ≡ b (mod n). Gives minimal residue and general solution family.

EquationModulus

Finds x ≡ rᵢ (mod mᵢ). Handles non‑coprime moduli if consistent; returns least nonnegative residue and combined modulus.

Residue & Congruence Check
Modular Inverse
Exists only if gcd(a,n)=1.
Results
Exportable
Time Tool Inputs Result Steps
Example Data

Click Load to populate inputs with an example.

TypeProblemExpected
Linear 14x ≡ 30 (mod 100) x ≡ 45 (mod 50) Load
Linear 35x ≡ 10 (mod 50) x ≡ 6 (mod 10) Load
Linear 6x ≡ 5 (mod 15) No solution Load
CRT x ≡ 2 (mod 3), 3 (mod 5), 2 (mod 7) x ≡ 23 (mod 105) Load
Check 1001 ≡ 1 (mod 10) True Load
Formulas Used
  1. Residue: a mod n = a − n ⌊a/n⌋; returned in [0, n−1].
  2. Congruence: a ≡ b (mod n) iff n | (a − b).
  3. Linear congruence: For a·x ≡ b (mod n), let g=gcd(a,n).
    If g ∤ b, no solution. Otherwise set a'=a/g, b'=b/g, n'=n/g. Let a'⁻¹ be the modular inverse of a' modulo n'. Then one solution is x₀ ≡ a'⁻¹·b' (mod n'), and the general solution family is x ≡ x₀ + k·n'.
  4. Modular inverse: a⁻¹ mod n exists iff gcd(a,n)=1. Computed via extended Euclid.
  5. Chinese Remainder (general): Combine two congruences x ≡ r₁ (mod m₁), x ≡ r₂ (mod m₂). Let g=gcd(m₁,m₂). If (r₂−r₁) mod g ≠ 0, inconsistent. Otherwise the merged modulus is lcm(m₁,m₂)=m₁·m₂/g, and one solution is
    x ≡ r₁ + m₁ · [( (r₂−r₁)/g ) · ( (m₁/g)⁻¹ mod (m₂/g) ) ] (mod lcm), reduced to the least residue.
How to Use This Calculator
  • Choose Linear Congruence to solve a·x ≡ b (mod n). Enter a, b, and n, then click Solve.
  • Use Chinese Remainder to combine several conditions x ≡ rᵢ (mod mᵢ). Add rows as needed and click Solve CRT.
  • Open Quick Tools for residues, congruence checks, and modular inverse.
  • Results appear in the table below. Use Download CSV or Download PDF to export.
  • Click an example’s Load to auto‑fill inputs for a quick demo.
Reference: Euler’s Totient φ(n) & Unit Group Size

φ(n) counts integers in [1,n] relatively prime to n. The multiplicative group of units modulo n has size φ(n).

nPrime factorizationφ(n)Notes
221Units: {1}
332Prime; group cyclic
42Units: {1,3}
554Prime; group cyclic
62·32Units: {1,5}
776Prime; group cyclic
84Units: {1,3,5,7}
96Units: {1,2,4,5,7,8}
102·54
111110Prime; group cyclic
122²·34
153·58
162⁴8
182·3²6
202²·58
213·712
222·1110
242³·38
2520
262·1312
282²·712
302·3·58
Reference: Congruence Identities & Shortcuts
RuleStatementExample
Normalizationa ≡ a mod n123 ≡ 3 (mod 10)
Add/Subtracta≡b, c≡d ⇒ a±c≡b±d14≡4, 9≡-1 ⇒ 23≡3 (mod 10)
Multiplya≡b ⇒ ka≡kb7≡-1 ⇒ 3·7≡-3 (mod 8)
Cancellationca≡cb and gcd(c,n)=1 ⇒ a≡b2x≡2 (mod 5) ⇒ x≡1
Poweringa≡b ⇒ a^k≡b^k3≡-2 (mod 5) ⇒ 3⁴≡(-2)⁴
Eulergcd(a,n)=1 ⇒ a^{φ(n)}≡1a^{40}≡1 (mod 41)
Fermatp prime, p∤a ⇒ a^{p-1}≡12^{10}≡1 (mod 11)
CRT MergeCombine x≡rᵢ (mod mᵢ)x≡2 (3), 3 (5), 2 (7) ⇒ 23 (105)

Use cancellation only when the factor is a unit modulo n (i.e., coprime to n).

FAQs

It means n divides a − b, or equivalently that a and b have the same remainder when divided by n.

If g=gcd(a,n) does not divide b, then a·x ≡ b (mod n) is impossible. Otherwise there are g congruence classes of solutions.

No. a⁻¹ mod n exists only if gcd(a,n)=1. Otherwise the inverse is undefined.

No. This tool supports the generalized CRT: non‑coprime moduli are allowed if the congruences are pairwise consistent modulo the gcds.

We show reductions, gcds via extended Euclid, inverses when they exist, and the construction of the general solution or CRT merge.

We return the least non‑negative residue in [0, m−1] for modulus m, alongside the general solution description.

Inputs are 64‑bit integers in JavaScript. Extremely large moduli may overflow or slow down computations in the browser.
Tips
  • Keep moduli positive for standard residue classes.
  • Use the CRT when multiple modular conditions must hold simultaneously.
  • For speed, reduce inputs using residues before solving.
  • Toggle “Show steps” to condense or expand derivations.
About

Single‑file calculator with white theme. Accessible controls, exportable results, example problems, and clear derivations for learning and verification.

Need a permalink? Press Enter to submit.

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.