Chinese Remainder Theorem Calculator

Solve systems of congruences with the Chinese Remainder Theorem Calculator. Enter remainders and moduli to find the minimum solution and general form instantly.

892.1K uses Updated · 2026-05-04 Runs locally · zero upload
AD

How to Use Chinese Remainder Theorem Calculator

The Chinese Remainder Theorem Calculator solves systems of simultaneous congruences. Each row represents one equation of the form x ≡ aᵢ (mod mᵢ). Fill in the rows and the Chinese Remainder Theorem Calculator computes the minimum non-negative solution and the general form immediately.

  1. Enter remainders and moduli — for each row, type the remainder aᵢ and the modulus mᵢ. Add more rows with the “Add Congruence” button for systems with more than three equations.
  2. Check pairwise coprimality — the Chinese Remainder Theorem Calculator automatically verifies that all moduli are pairwise coprime. If they are not, an error message explains why.
  3. Read the solution — the result panel shows the minimum non-negative solution x, the general solution form x ≡ r (mod M), the total modulus M, and a step-by-step table with Mᵢ, yᵢ, and aᵢMᵢyᵢ values.

You can add up to any number of congruences. Remove a row by clicking the ✕ button next to it.

Formula & Theory - Chinese Remainder Theorem Calculator

The Chinese Remainder Theorem Calculator implements the standard CRT construction:

Given: x ≡ a₁ (mod m₁), x ≡ a₂ (mod m₂), ..., x ≡ aₙ (mod mₙ)
Require: m₁, m₂, ..., mₙ pairwise coprime

M  = m₁ × m₂ × ... × mₙ
Mᵢ = M / mᵢ
yᵢ = modular inverse of Mᵢ with respect to mᵢ  (Mᵢ · yᵢ ≡ 1 mod mᵢ)
x  = (Σ aᵢ · Mᵢ · yᵢ) mod M
SymbolMeaning
MProduct of all moduli
MᵢM divided by the i-th modulus
yᵢModular inverse of Mᵢ modulo mᵢ
xMinimum non-negative solution

The theorem guarantees a unique solution modulo M when all moduli are pairwise coprime. The Chinese Remainder Theorem Calculator uses the Extended Euclidean Algorithm to compute each modular inverse, ensuring correctness for arbitrarily large moduli (within JavaScript’s safe integer range).

Assumptions and Limits

  • All moduli must be positive integers greater than 1.
  • Remainders can be any integer; negative remainders are automatically normalized.
  • The CRT as implemented requires pairwise coprime moduli. Generalized CRT for non-coprime moduli is outside the scope of this calculator.
  • Large moduli may exceed JavaScript’s safe integer range (2⁵³ − 1). For very large inputs, consider specialized big-integer tools.

Use Cases for Chinese Remainder Theorem Calculator

The Chinese Remainder Theorem Calculator is useful in both academic and applied settings. Common scenarios include:

  • Number theory homework — quickly solve CRT problems assigned in discrete mathematics or abstract algebra courses.
  • Cryptography foundations — CRT is a core technique in RSA optimization (Chinese Remainder Theorem form of RSA), Diffie-Hellman key exchange, and other public-key algorithms.
  • Algorithm competitions — competitive programming problems frequently involve simultaneous congruences; the Chinese Remainder Theorem Calculator lets you verify answers before submitting.
  • Clock arithmetic puzzles — classic puzzles such as “a number leaves remainder 2 when divided by 3, remainder 3 when divided by 5, …” are solved instantly.

The step-by-step table makes the Chinese Remainder Theorem Calculator especially useful for learning the algorithm, not just getting answers.

Frequently asked questions about Chinese Remainder Theorem Calculator

What does the Chinese Remainder Theorem Calculator solve?

The Chinese Remainder Theorem Calculator finds the smallest non-negative integer x that simultaneously satisfies a set of congruence equations: x ≡ a₁ (mod m₁), x ≡ a₂ (mod m₂), and so on.

When can the Chinese Remainder Theorem be applied?

The classical CRT requires pairwise coprime moduli. If any two moduli share a common factor greater than 1, the Chinese Remainder Theorem Calculator will inform you that the theorem cannot be directly applied.

How does the modular inverse calculation work?

The calculator uses the Extended Euclidean Algorithm to find each yᵢ such that Mᵢ · yᵢ ≡ 1 (mod mᵢ), where Mᵢ = M / mᵢ and M is the product of all moduli.

Is my data stored?

No. All calculations happen in your browser; nothing is sent to a server.