Two coprime moduli
Du skriver inn
- Kongruenser
- 2, 3; 3, 5
Du får
- X
- 8
- Modulus
- 15
- Ligning
- x ≡ 8 (mod 15)
8 leaves remainder 2 when divided by 3 and remainder 3 when divided by 5. Every solution has the form 8 + 15k.
Kjørt med verktøyets egen kode.
Gratis å bruke, uten konto
Løs et system av kongruenser og se den minste ikke-negative løsningen med samlet modulus. Også kompatible moduli som ikke er primiske, fungerer; motstridende systemer forklares.
Skriv én rest og én modul på hver linje, atskilt med komma, for eksempel 2, 3 for x ≡ 2 (mod 3). Legg til 2–20 linjer og beregn. Resultatet viser den minste ikke-negative x-verdien og den kombinerte modulen.
Veiledning
This calculator solves a system of congruences, such as x ≡ 2 (mod 3) and x ≡ 3 (mod 5), with the Chinese remainder theorem. You enter one remainder and one modulus per line, and it returns the smallest non-negative x that fits every line, plus the combined modulus. It also handles moduli that share a factor when the lines agree, and it reports a conflict when no number can fit.
8 leaves remainder 2 when divided by 3 and remainder 3 when divided by 5. Every solution has the form 8 + 15k.
Kjørt med verktøyets egen kode.
The first two lines combine to 8 mod 15, and adding the third gives 23 mod 105. Check: 23 leaves 2 on division by 3, 3 on division by 5 and 2 on division by 7.
Kjørt med verktøyets egen kode.
The moduli 4 and 8 share the factor 4, and both lines agree mod 4, since 2 and 6 both leave 2. The combined modulus is the least common multiple, 8.
Kjørt med verktøyets egen kode.
The numbers 4 and 6 have gcd 2, but 1 and 2 differ by 1, which is not divisible by 2. In plain terms, x ≡ 1 (mod 4) forces x to be odd while x ≡ 2 (mod 6) forces it to be even.
Kjørt med verktøyets egen kode.
A remainder of −1 mod 5 is treated as 4. Then 24 leaves 4 on division by 5 and 3 on division by 7, and 35 is 5 times 7.
Kjørt med verktøyets egen kode.
For moduli that are pairwise coprime, any set of remainders is matched by exactly one number in each block of length equal to the product of the moduli. This tool also covers moduli that share factors, where a solution exists only if the remainders agree on those shared factors.
It is the one answer between 0 and M − 1, where M is the combined modulus. Any other answer is found by adding or subtracting multiples of M. For x ≡ 8 (mod 15), the numbers 8, 23, 38 and −7 are all valid.
Yes. If the lines agree modulo the greatest common divisor, they combine, and the new modulus is the least common multiple. If they disagree, the page reports the system as incompatible and shows the row, the gcd and the difference.
The result says the system is incompatible. It shows which line caused the conflict with the earlier lines, the greatest common divisor of the two moduli involved, and the difference between the remainders, which that gcd cannot divide.
Yes for remainders. A remainder is reduced to the range 0 up to the modulus minus 1, so −1 mod 5 becomes 4 and 5 mod 3 becomes 2. Moduli must be at least 2, so negative or zero moduli are refused.
No. It uses exact BigInt integer arithmetic inside the stated limits. That is why the combined modulus can be very large, for example about 10^24 for two inputs near 10^12, with no rounding.
No. The page says the calculation runs in your browser, and the code works only on the text in the box. Nothing is saved or sent to a server.
Skriv én rest og én modul på hver linje, atskilt med komma, for eksempel 2, 3 for x ≡ 2 (mod 3). Legg til 2–20 linjer og beregn. Resultatet viser den minste ikke-negative x-verdien og den kombinerte modulen.
Nei. Beregningen kjøres i nettleseren med eksakt heltallsregning. Verdiene du skriver inn, lastes ikke opp eller lagres av dette verktøyet.
Det kombinerer kongruenser til én gjentakende løsningsklasse. For eksempel blir x ≡ 2 (mod 3) og x ≡ 3 (mod 5) til x ≡ 8 (mod 15).
Ja, når kongruensene stemmer overens modulo største felles divisor. For eksempel kombineres x ≡ 2 (mod 4) og x ≡ 6 (mod 8) til x ≡ 6 (mod 8). Motstridende systemer rapporteres som uløselige.
Ja. Den bruker lokal BigInt-heltallsaritmetikk i stedet for flyttall, innenfor inndatagrensene som vises ovenfor.