GenerateRandomSearch

Chinese Remainder Challenge Generator

A number that leaves remainder 2 when divided by 3, 3 when divided by 5, and 2 when divided by 7 — Sun Tzu asked it in the third century, and the answer is 23. The theorem says that whenever the moduli are pairwise coprime there is exactly one answer below their product, and every problem here is built that way round: the answer is chosen first and the remainders derived from it, so a solution is guaranteed to exist.

What this generator does

Picks pairwise coprime moduli, chooses an answer below their product, and derives each congruence from it. The result is a system that always has exactly one solution in range, with the product stated so the general solution is clear.

How to use this tool

  1. Choose how many congruences you want.
  2. Solve the system by searching or by the standard construction.
  3. Reveal the answer and the product the solution is unique below.
  4. Check by dividing your answer by each modulus in turn.

Understanding the controls

How many congruences
Between 2 and 4. Each one added multiplies the range the answer is unique within.
Seed
Reproduces the same moduli and remainders, so a problem can be set and marked later.
Show the answer
Reveals the solution and the product of the moduli that every other solution differs by.

Common use cases

  • Practice problems for the Chinese remainder theorem with guaranteed solutions
  • Showing why pairwise coprime moduli are the condition, not a convenience
  • Calendar and cycle problems in their abstract form
  • Verifying a modular solver against known answers
  • Setting the same system twice from a seed

How this generator works

Moduli are drawn from a small set and rejected unless coprime to all those already chosen. The check substitutes the stated solution into every congruence, confirms all moduli are pairwise coprime, and requires the answer to lie below their product — the range in which the theorem promises uniqueness.

Randomness and fairness

The moduli and the answer are random; that a solution exists and is unique follows from coprimality. Seeded systems reproduce exactly and are therefore explicitly not cryptographically secure, and unseeded ones use the browser's cryptographically secure generator.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • Moduli come from a fixed small set, so the same ones recur.
  • Systems always have a solution by construction; the unsolvable non-coprime case is described but not generated.
  • No construction is shown, only the answer — the search method is left to you.
  • Congruences are in one unknown only.
  • Systems are not stored between visits.

Privacy and your data

Moduli, remainders and the solution are computed in your browser. Nothing is transmitted or retained.