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
8598890859010
889859130101
85930281901-28
30191111-2829
191118-2829-57
1181329-5786
8322-5786-229
321186-229315
2120-229315-859
So our multiplicative inverse is 315 mod 859 ≡ 315
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4859220485010
9224851437101
48543714801-1
43748951-110
48593-110-91
531210-91101
3211-91101-192
2120101-192485
So our multiplicative inverse is -192 mod 485 ≡ 293
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
423302112101-1
3021212601-13
1216021-13-7
6016003-7423
So our multiplicative inverse is -7 mod 423 ≡ 416
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 ≡ 354 × 889-1 (mod 859) ≡ 354 × 315 (mod 859) ≡ 699 (mod 859)
x ≡ 312 × 922-1 (mod 485) ≡ 312 × 293 (mod 485) ≡ 236 (mod 485)
x ≡ 756 × 302-1 (mod 423) ≡ 756 × 416 (mod 423) ≡ 207 (mod 423)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 859 × 485 × 423 = 176228145
  2. We calculate the numbers M1 to M3
    M1=M/m1=176228145/859=205155,   M2=M/m2=176228145/485=363357,   M3=M/m3=176228145/423=416615
  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
    8592051550859010
    205155859238713101
    859713114601-1
    71314641291-15
    146129117-15-6
    129177105-647
    171017-647-53
    1071347-53100
    7321-53100-253
    3130100-253859
    So our multiplicative inverse is -253 mod 859 ≡ 606
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4853633570485010
    36335748574992101
    4859252501-5
    92253171-516
    251718-516-21
    1782116-2158
    8180-2158-485
    So our multiplicative inverse is 58 mod 485 ≡ 58
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4234166150423010
    416615423984383101
    42338314001-1
    383409231-110
    4023117-110-11
    23171610-1121
    17625-1121-53
    651121-5374
    5150-5374-423
    So our multiplicative inverse is 74 mod 423 ≡ 74
    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
    =  (699 × 205155 × 606 +
       236 × 363357 × 58 +
       207 × 416615 × 74)   mod 176228145
    = 98689491 (mod 176228145)


    So our answer is 98689491 (mod 176228145).


Verification

So we found that x ≡ 98689491
If this is correct, then the following statements (i.e. the original equations) are true:
889x (mod 859) ≡ 354 (mod 859)
922x (mod 485) ≡ 312 (mod 485)
302x (mod 423) ≡ 756 (mod 423)

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