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
8299191001-9
9110911-982
101100-982-829
So our multiplicative inverse is 82 mod 829 ≡ 82
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1977630197010
7631973172101
19717212501-1
172256221-17
252213-17-8
223717-863
3130-863-197
So our multiplicative inverse is 63 mod 197 ≡ 63
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
63915442301-4
154236161-425
231617-425-29
1672225-2983
7231-2983-278
212083-278639
So our multiplicative inverse is -278 mod 639 ≡ 361
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 ≡ 412 × 91-1 (mod 829) ≡ 412 × 82 (mod 829) ≡ 624 (mod 829)
x ≡ 983 × 763-1 (mod 197) ≡ 983 × 63 (mod 197) ≡ 71 (mod 197)
x ≡ 789 × 154-1 (mod 639) ≡ 789 × 361 (mod 639) ≡ 474 (mod 639)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 829 × 197 × 639 = 104357007
  2. We calculate the numbers M1 to M3
    M1=M/m1=104357007/829=125883,   M2=M/m2=104357007/197=529731,   M3=M/m3=104357007/639=163313
  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
    8291258830829010
    125883829151704101
    829704112501-1
    7041255791-16
    12579146-16-7
    79461336-713
    4633113-713-20
    33132713-2053
    13716-2053-73
    761153-73126
    6160-73126-829
    So our multiplicative inverse is 126 mod 829 ≡ 126
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1975297310197010
    5297311972688195101
    1971951201-1
    19529711-198
    2120-198-197
    So our multiplicative inverse is 98 mod 197 ≡ 98
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6391633130639010
    163313639255368101
    639368127101-1
    3682711971-12
    27197277-12-5
    97771202-57
    7720317-57-26
    2017137-2633
    17352-2633-191
    321133-191224
    2120-191224-639
    So our multiplicative inverse is 224 mod 639 ≡ 224
    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
    =  (624 × 125883 × 126 +
       71 × 529731 × 98 +
       474 × 163313 × 224)   mod 104357007
    = 33540306 (mod 104357007)


    So our answer is 33540306 (mod 104357007).


Verification

So we found that x ≡ 33540306
If this is correct, then the following statements (i.e. the original equations) are true:
91x (mod 829) ≡ 412 (mod 829)
763x (mod 197) ≡ 983 (mod 197)
154x (mod 639) ≡ 789 (mod 639)

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