Skip to content

Chinese remainder calculator

You know how many are left over when the SAME total is grouped in different ways. Enter those clues to find the smallest possible total.

Find the unknown total

Processed in your browser.

You know how many are left over when the SAME total is grouped in different ways. Enter those clues to find the smallest possible total.

Put one clue in each row: group size on the left, items left over on the right. Complete at least two rows. Leave unused rows empty.

Groups of 3 leave 2 over. Groups of 5 leave 3 over.Smallest possible total: 8

These conditions work together. The smallest matching number is 8.

Chinese remainder result

Enter at least two clues to find the total.

How to use

You know how many are left over when the SAME total is grouped in different ways. Enter those clues to find the smallest possible total. Put one clue in each row: group size on the left, items left over on the right. Complete at least two rows. Leave unused rows empty. You are looking for one total that fits every clue. For example, put 3 and 2 in the first row: this says groups of three leave two items over. Put 5 and 3 in the second row: groups of five leave three over. Eight fits both clues. You can make two groups of three from eight, with two left over, or one group of five, with three left over. The answer is the unknown total, not a number to type into either field. Each row describes the same collection, regrouped from scratch.

Complete both fields in each row you use. The gray rows are only a starting example and all clear together on first focus. The live hint responds to your current row, explains conflicts, and suggests a compatible value when possible.

Method and result reading

The calculator combines the conditions one at a time. Shared factors are allowed when their required remainders agree; the combined repeat length is the least common multiple. Exact BigInt arithmetic avoids rounding.

The main result is x₀. General solution is x = x₀ + kM for every integer k. Normalized remainders shows how negative or oversized inputs were reduced. Substitution checks independently computes x₀ mod mᵢ for every original row. All operations use BigInt, so there is no floating-point rounding.

Worked examples

For x ≡ 2 (mod 3), x ≡ 3 (mod 5), and x ≡ 2 (mod 7), the product is 105 and the standard solution is 23. The checks read 23 mod 3 = 2, 23 mod 5 = 3, and 23 mod 7 = 2. Every other solution is 23 + 105k.

For remainders −1, 8 and moduli 5, 3, normalization gives 4, 2. The smallest solution is 14 because 14 mod 5 is 4 and 14 mod 3 is 2. Negative input is therefore supported; the output still uses the standard nonnegative representative.

Scope, limits, and errors

Divisors only need to be positive; they do not need to be prime or coprime. If shared factors demand different remainders, no number can satisfy every condition and the calculator says so.

Use two to four complete rows. Each field takes one integer of up to 100 significant digits. Group sizes must be positive. Blank rows are ignored; a partly filled row needs its other value. The live hints show the usual leftover range for your group size. Negative or oversized remainders are still supported by the mathematical model and normalized before calculating.

Using the output

Use the smallest representative when a problem asks for the least nonnegative answer. Use the general expression when describing the whole congruence class or finding a later positive solution. Copy result includes x₀, the period M, normalized inputs, and every substitution check as plain text. For cryptographic or production protocols, use a reviewed big-integer library and protocol implementation; this educational calculator does not make a security claim.

Why the verification matters

A CRT construction can look plausible while a sign, inverse, or row order is wrong. Reapplying every modulus is a direct end-to-end check of the returned value. It does not rely on the same presentation text or on decimal approximation. If you rearrange the input rows, the standard solution and period should remain the same because the set of congruences is unchanged.

FAQ

Can remainders be negative?

Yes. They are normalized before solving.

Must moduli be prime?

No. Any positive divisors are accepted.

What does k mean?

Any integer; changing k selects another solution in the same class.

Are non-coprime systems impossible?

They are solved automatically when compatible; otherwise the calculator reports no solution.

Is the answer rounded?

No. Every value and check is exact.