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
53375053010
3755374101
53413101-13
41401-1353
So our multiplicative inverse is -13 mod 53 ≡ 40
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
987856113101-1
8561316701-17
13170161-17-8
7061197-815
61967-815-98
971215-98113
7231-98113-437
2120113-437987
So our multiplicative inverse is -437 mod 987 ≡ 550
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
95828939101-3
289913161-310
9116511-310-53
16111510-5363
11521-5363-179
515063-179958
So our multiplicative inverse is -179 mod 958 ≡ 779
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 ≡ 378 × 375-1 (mod 53) ≡ 378 × 40 (mod 53) ≡ 15 (mod 53)
x ≡ 816 × 856-1 (mod 987) ≡ 816 × 550 (mod 987) ≡ 702 (mod 987)
x ≡ 774 × 289-1 (mod 958) ≡ 774 × 779 (mod 958) ≡ 364 (mod 958)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 53 × 987 × 958 = 50113938
  2. We calculate the numbers M1 to M3
    M1=M/m1=50113938/53=945546,   M2=M/m2=50113938/987=50774,   M3=M/m3=50113938/958=52311
  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
    53945546053010
    945546531784026101
    53262101-2
    2612601-253
    So our multiplicative inverse is -2 mod 53 ≡ 51
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    987507740987010
    5077498751437101
    987437211301-2
    4371133981-27
    11398115-27-9
    9815687-961
    15817-961-70
    871161-70131
    7170-70131-987
    So our multiplicative inverse is 131 mod 987 ≡ 131
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    958523110958010
    5231195854579101
    958579137901-1
    57937912001-12
    3792001179-12-3
    2001791212-35
    17921811-35-43
    21111105-4348
    111011-4348-91
    10110048-91958
    So our multiplicative inverse is -91 mod 958 ≡ 867
    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
    =  (15 × 945546 × 51 +
       702 × 50774 × 131 +
       364 × 52311 × 867)   mod 50113938
    = 1554240 (mod 50113938)


    So our answer is 1554240 (mod 50113938).


Verification

So we found that x ≡ 1554240
If this is correct, then the following statements (i.e. the original equations) are true:
375x (mod 53) ≡ 378 (mod 53)
856x (mod 987) ≡ 816 (mod 987)
289x (mod 958) ≡ 774 (mod 958)

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