Bootstrap
  C.R.T. .com
It doesn't have to be difficult if someone just explains it right.

Welcome to ChineseRemainderTheorem.com!

×

Modal Header

Some text in the Modal Body

Some other text...

Use the calculator below to get a step-by-step calculation of the Chinese Remainder Theory. Just enter the numbers you would like and press "Calculate" .


This removes all numbers from the textboxes, such that you can fill in your own.

This fills all textboxes with random numbers. If you fill in random numbers yourself, it is very likely that those numbers do not have a solution. To avoid disappointment, use this button instead! It only uses random numbers that do have a solution.

This button is similar to the "Clear everything" button, but only clears the left column.
This is useful if you want your equations to be of the form x ≡ a (mod m) rather than bx ≡ a (mod m).
In that case, it can be especially useful after using the random numbers button.

Do you want to use more equations? Go ahead and use this button. It adds another row that you can fill in. Not sure what numbers to put in this newly added row? Use the random numbers button again!

Do you have too many rows? Use one of these buttons to remove a row. You can always add a row again using the yellow "Add a row" button.

Are you ready to view a full step-by-step Chinese Remainder Theorem calculation for the numbers you have entered? Then use this button!

Want to know more?


Transform the equations

You used one or more of the fields on the left, so your equations are of the form bx ≡ a mod m.
We want them to be of the form x ≡ a mod m, so we need to move the values on the left to the right side of the equation.
For a more detailed explanation about how this works, see this part of our page about how to execute the Chinese Remainder algorithm.

First, we calculate the inverses of the leftmost value on each row:

nbqr t1t2t3
991856113501-1
8561356461-17
13546243-17-15
4643137-1522
433141-1522-323
313022-323991
So our multiplicative inverse is -323 mod 991 ≡ 668
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
72334124101-2
341418131-217
411332-217-53
1326117-53335
2120-53335-723
So our multiplicative inverse is 335 mod 723 ≡ 335
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
923154515301-5
154153111-56
15311530-56-923
So our multiplicative inverse is 6 mod 923 ≡ 6
Source: ExtendedEuclideanAlgorithm.com

Click on any row to reveal a more detailed calculation of each multiplicative inverse.

Now that we now the inverses, let's move the leftmost value on each row to the right of the equation:

x ≡ 665 × 856-1 (mod 991) ≡ 665 × 668 (mod 991) ≡ 252 (mod 991)
x ≡ 980 × 341-1 (mod 723) ≡ 980 × 335 (mod 723) ≡ 58 (mod 723)
x ≡ 822 × 154-1 (mod 923) ≡ 822 × 6 (mod 923) ≡ 317 (mod 923)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 991 × 723 × 923 = 661323039
  2. We calculate the numbers M1 to M3
    M1=M/m1=661323039/991=667329,   M2=M/m2=661323039/723=914693,   M3=M/m3=661323039/923=716493
  3. We now calculate the modular multiplicative inverses M1-1 to M3-1
    Have a look at the page that explains how to calculate modular multiplicative inverse.
    Using, for example, the Extended Euclidean Algorithm, we will find that:

    nbqr t1t2t3
    9916673290991010
    667329991673386101
    991386221901-2
    38621911671-23
    219167152-23-5
    167523113-518
    521148-518-77
    1181318-7795
    8322-7795-267
    321195-267362
    2120-267362-991
    So our multiplicative inverse is 362 mod 991 ≡ 362
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7239146930723010
    914693723126598101
    7239873701-7
    98372241-715
    3724113-715-22
    241311115-2237
    131112-2237-59
    1125137-59332
    2120-59332-723
    So our multiplicative inverse is 332 mod 723 ≡ 332
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9237164930923010
    716493923776245101
    923245318801-3
    2451881571-34
    18857317-34-15
    5717364-1549
    17625-1549-113
    651149-113162
    5150-113162-923
    So our multiplicative inverse is 162 mod 923 ≡ 162
    Source: ExtendedEuclideanAlgorithm.com
  4. Now we can calculate x with the equation we saw earlier
    x = (a1 × M1 × M1-1   +   a2 × M2 × M2-1   + ... +   ak × Mk × Mk-1)   mod M
    =  (252 × 667329 × 362 +
       58 × 914693 × 332 +
       317 × 716493 × 162)   mod 661323039
    = 214321840 (mod 661323039)


    So our answer is 214321840 (mod 661323039).


Verification

So we found that x ≡ 214321840
If this is correct, then the following statements (i.e. the original equations) are true:
856x (mod 991) ≡ 665 (mod 991)
341x (mod 723) ≡ 980 (mod 723)
154x (mod 923) ≡ 822 (mod 923)

Let's see whether that's indeed the case if we use x ≡ 214321840.