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
971204415501-4
2041551491-45
1554938-45-19
498615-19119
8180-19119-971
So our multiplicative inverse is 119 mod 971 ≡ 119
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
643266211101-2
2661112441-25
11144223-25-12
44231215-1217
232112-1217-29
21210117-29307
2120-29307-643
So our multiplicative inverse is 307 mod 643 ≡ 307
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5718730571010
8735711302101
571302126901-1
3022691331-12
2693385-12-17
335632-17104
5312-17104-121
3211104-121225
2120-121225-571
So our multiplicative inverse is 225 mod 571 ≡ 225
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 ≡ 895 × 204-1 (mod 971) ≡ 895 × 119 (mod 971) ≡ 666 (mod 971)
x ≡ 291 × 266-1 (mod 643) ≡ 291 × 307 (mod 643) ≡ 603 (mod 643)
x ≡ 306 × 873-1 (mod 571) ≡ 306 × 225 (mod 571) ≡ 330 (mod 571)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 971 × 643 × 571 = 356505563
  2. We calculate the numbers M1 to M3
    M1=M/m1=356505563/971=367153,   M2=M/m2=356505563/643=554441,   M3=M/m3=356505563/571=624353
  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
    9713671530971010
    367153971378115101
    97111585101-8
    115512131-817
    5113312-817-59
    13121117-5976
    121120-5976-971
    So our multiplicative inverse is 76 mod 971 ≡ 76
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6435544410643010
    554441643862175101
    643175311801-3
    1751181571-34
    1185724-34-11
    5741414-11158
    4140-11158-643
    So our multiplicative inverse is 158 mod 643 ≡ 158
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5716243530571010
    6243535711093250101
    57125027101-2
    250713371-27
    7137134-27-9
    3734137-916
    343111-916-185
    313016-185571
    So our multiplicative inverse is -185 mod 571 ≡ 386
    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
    =  (666 × 367153 × 76 +
       603 × 554441 × 158 +
       330 × 624353 × 386)   mod 356505563
    = 135860073 (mod 356505563)


    So our answer is 135860073 (mod 356505563).


Verification

So we found that x ≡ 135860073
If this is correct, then the following statements (i.e. the original equations) are true:
204x (mod 971) ≡ 895 (mod 971)
266x (mod 643) ≡ 291 (mod 643)
873x (mod 571) ≡ 306 (mod 571)

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