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
6678920667010
8926671225101
667225221701-2
225217181-23
2178271-23-83
81803-83667
So our multiplicative inverse is -83 mod 667 ≡ 584
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5418480541010
8485411307101
541307123401-1
3072341731-12
23473315-12-7
73154132-730
151312-730-37
1326130-37252
2120-37252-541
So our multiplicative inverse is 252 mod 541 ≡ 252
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
641538110301-1
5381035231-16
10323411-16-25
2311216-2556
111110-2556-641
So our multiplicative inverse is 56 mod 641 ≡ 56
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 ≡ 570 × 892-1 (mod 667) ≡ 570 × 584 (mod 667) ≡ 47 (mod 667)
x ≡ 120 × 848-1 (mod 541) ≡ 120 × 252 (mod 541) ≡ 485 (mod 541)
x ≡ 105 × 538-1 (mod 641) ≡ 105 × 56 (mod 641) ≡ 111 (mod 641)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 667 × 541 × 641 = 231302927
  2. We calculate the numbers M1 to M3
    M1=M/m1=231302927/667=346781,   M2=M/m2=231302927/541=427547,   M3=M/m3=231302927/641=360847
  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
    6673467810667010
    346781667519608101
    66760815901-1
    6085910181-111
    591835-111-34
    1853311-34113
    5312-34113-147
    3211113-147260
    2120-147260-667
    So our multiplicative inverse is 260 mod 667 ≡ 260
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5414275470541010
    427547541790157101
    54115737001-3
    157702171-37
    701742-37-31
    172817-31255
    2120-31255-541
    So our multiplicative inverse is 255 mod 541 ≡ 255
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6413608470641010
    360847641562605101
    64160513601-1
    6053616291-117
    362917-117-18
    2974117-1889
    7170-1889-641
    So our multiplicative inverse is 89 mod 641 ≡ 89
    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
    =  (47 × 346781 × 260 +
       485 × 427547 × 255 +
       111 × 360847 × 89)   mod 231302927
    = 77979684 (mod 231302927)


    So our answer is 77979684 (mod 231302927).


Verification

So we found that x ≡ 77979684
If this is correct, then the following statements (i.e. the original equations) are true:
892x (mod 667) ≡ 570 (mod 667)
848x (mod 541) ≡ 120 (mod 541)
538x (mod 641) ≡ 105 (mod 641)

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