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
2117870211010
7872113154101
21115415701-1
154572401-13
5740117-13-4
4017263-411
17625-411-26
651111-2637
5150-2637-211
So our multiplicative inverse is 37 mod 211 ≡ 37
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4027070402010
7074021305101
40230519701-1
305973141-14
9714613-14-25
1413114-2529
131130-2529-402
So our multiplicative inverse is 29 mod 402 ≡ 29
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4096190409010
6194091210101
409210119901-1
2101991111-12
19911181-12-37
1111102-37409
So our multiplicative inverse is -37 mod 409 ≡ 372
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 ≡ 74 × 787-1 (mod 211) ≡ 74 × 37 (mod 211) ≡ 206 (mod 211)
x ≡ 72 × 707-1 (mod 402) ≡ 72 × 29 (mod 402) ≡ 78 (mod 402)
x ≡ 40 × 619-1 (mod 409) ≡ 40 × 372 (mod 409) ≡ 156 (mod 409)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 211 × 402 × 409 = 34692198
  2. We calculate the numbers M1 to M3
    M1=M/m1=34692198/211=164418,   M2=M/m2=34692198/402=86299,   M3=M/m3=34692198/409=84822
  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
    2111644180211010
    16441821177949101
    2114941501-4
    4915341-413
    15433-413-43
    431113-4356
    3130-4356-211
    So our multiplicative inverse is 56 mod 211 ≡ 56
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    402862990402010
    86299402214271101
    402271113101-1
    271131291-13
    1319145-13-43
    95143-4346
    5411-4346-89
    414046-89402
    So our multiplicative inverse is -89 mod 402 ≡ 313
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    409848220409010
    84822409207159101
    40915929101-2
    159911681-23
    9168123-23-5
    68232223-513
    232211-513-18
    22122013-18409
    So our multiplicative inverse is -18 mod 409 ≡ 391
    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
    =  (206 × 164418 × 56 +
       78 × 86299 × 313 +
       156 × 84822 × 391)   mod 34692198
    = 18692274 (mod 34692198)


    So our answer is 18692274 (mod 34692198).


Verification

So we found that x ≡ 18692274
If this is correct, then the following statements (i.e. the original equations) are true:
787x (mod 211) ≡ 74 (mod 211)
707x (mod 402) ≡ 72 (mod 402)
619x (mod 409) ≡ 40 (mod 409)

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