Generalized congruence system

Solve remainder-modulus conditions with exact integers, including compatible non-coprime moduli.

The example value has been entered. Check it immediately or change the value.

Input is processed in the browser. Refreshing returns a sample value.

Result

Instructions and example

x≡a (mod m), x≡b (mod n); (b−a) mod gcd(m,n)=0; period=lcm(m,n)

x≡2 mod 3, x≡3 mod 5, x≡2 mod 7 have least nonnegative solution 23 and period 105.

At most 20 conditions with integer input magnitudes at most 1,000,000,000,000 and positive moduli. BigInt arithmetic is exact; combined periods exceeding 100 digits are rejected.

Frequently asked questions

Can non-coprime moduli have a solution?

Yes. Conditions combine when their remainder difference is divisible by the moduli’s greatest common divisor; otherwise no solution is reported.

How are negative remainders handled?

They are normalized to the same congruence class under a positive modulus. Results give the least nonnegative solution and the period of all solutions.

Calculation criteria and reference materials

Verification of calculation criteria: · Calculation·verification principles · Report errors