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
865508135701-1
50835711511-12
357151255-12-5
151552412-512
5541114-512-17
411421312-1746
141311-1746-63
13113046-63865
So our multiplicative inverse is -63 mod 865 ≡ 802
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6978430697010
8436971146101
697146411301-4
1461131331-45
11333314-45-19
3314255-1943
14524-1943-105
541143-105148
4140-105148-697
So our multiplicative inverse is 148 mod 697 ≡ 148
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1372950137010
295137221101
1372161101-6
21111101-67
111011-67-13
1011007-13137
So our multiplicative inverse is -13 mod 137 ≡ 124
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 ≡ 147 × 508-1 (mod 865) ≡ 147 × 802 (mod 865) ≡ 254 (mod 865)
x ≡ 519 × 843-1 (mod 697) ≡ 519 × 148 (mod 697) ≡ 142 (mod 697)
x ≡ 355 × 295-1 (mod 137) ≡ 355 × 124 (mod 137) ≡ 43 (mod 137)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 865 × 697 × 137 = 82597985
  2. We calculate the numbers M1 to M3
    M1=M/m1=82597985/865=95489,   M2=M/m2=82597985/697=118505,   M3=M/m3=82597985/137=602905
  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
    865954890865010
    95489865110339101
    865339218701-2
    33918711521-23
    187152135-23-5
    152354123-523
    3512211-523-51
    12111123-5174
    111110-5174-865
    So our multiplicative inverse is 74 mod 865 ≡ 74
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6971185050697010
    11850569717015101
    6971546701-46
    157211-4693
    7170-4693-697
    So our multiplicative inverse is 93 mod 697 ≡ 93
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1376029050137010
    6029051374400105101
    13710513201-1
    10532391-14
    32935-14-13
    95144-1317
    5411-1317-30
    414017-30137
    So our multiplicative inverse is -30 mod 137 ≡ 107
    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
    =  (254 × 95489 × 74 +
       142 × 118505 × 93 +
       43 × 602905 × 107)   mod 82597985
    = 21503289 (mod 82597985)


    So our answer is 21503289 (mod 82597985).


Verification

So we found that x ≡ 21503289
If this is correct, then the following statements (i.e. the original equations) are true:
508x (mod 865) ≡ 147 (mod 865)
843x (mod 697) ≡ 519 (mod 697)
295x (mod 137) ≡ 355 (mod 137)

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