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
6438730643010
8736431230101
643230218301-2
2301831471-23
18347342-23-11
4742153-1114
42582-1114-123
522114-123260
2120-123260-643
So our multiplicative inverse is 260 mod 643 ≡ 260
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6199260619010
9266191307101
6193072501-2
30756121-2123
5221-2123-248
2120123-248619
So our multiplicative inverse is -248 mod 619 ≡ 371
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2039180203010
9182034106101
20310619701-1
10697191-12
979107-12-21
97122-2123
7231-2123-90
212023-90203
So our multiplicative inverse is -90 mod 203 ≡ 113
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 ≡ 842 × 873-1 (mod 643) ≡ 842 × 260 (mod 643) ≡ 300 (mod 643)
x ≡ 414 × 926-1 (mod 619) ≡ 414 × 371 (mod 619) ≡ 82 (mod 619)
x ≡ 597 × 918-1 (mod 203) ≡ 597 × 113 (mod 203) ≡ 65 (mod 203)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 643 × 619 × 203 = 80797451
  2. We calculate the numbers M1 to M3
    M1=M/m1=80797451/643=125657,   M2=M/m2=80797451/619=130529,   M3=M/m3=80797451/203=398017
  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
    6431256570643010
    125657643195272101
    64327229901-2
    272992741-25
    9974125-25-7
    74252245-719
    252411-719-26
    24124019-26643
    So our multiplicative inverse is -26 mod 643 ≡ 617
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6191305290619010
    130529619210539101
    61953918001-1
    539806591-17
    8059121-17-8
    59212177-823
    211714-823-31
    1744123-31147
    4140-31147-619
    So our multiplicative inverse is 147 mod 619 ≡ 147
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2033980170203010
    3980172031960137101
    20313716601-1
    13766251-13
    665131-13-40
    51503-40203
    So our multiplicative inverse is -40 mod 203 ≡ 163
    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
    =  (300 × 125657 × 617 +
       82 × 130529 × 147 +
       65 × 398017 × 163)   mod 80797451
    = 43212472 (mod 80797451)


    So our answer is 43212472 (mod 80797451).


Verification

So we found that x ≡ 43212472
If this is correct, then the following statements (i.e. the original equations) are true:
873x (mod 643) ≡ 842 (mod 643)
926x (mod 619) ≡ 414 (mod 619)
918x (mod 203) ≡ 597 (mod 203)

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