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
691117510601-5
1171061111-56
1061197-56-59
117146-5965
7413-5965-124
431165-124189
3130-124189-691
So our multiplicative inverse is 189 mod 691 ≡ 189
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
7518030751010
803751152101
75152142301-14
5223261-1429
23635-1429-101
651129-101130
5150-101130-751
So our multiplicative inverse is 130 mod 751 ≡ 130
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1074450107010
445107417101
107176501-6
175321-619
5221-619-44
212019-44107
So our multiplicative inverse is -44 mod 107 ≡ 63
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 ≡ 97 × 117-1 (mod 691) ≡ 97 × 189 (mod 691) ≡ 367 (mod 691)
x ≡ 162 × 803-1 (mod 751) ≡ 162 × 130 (mod 751) ≡ 32 (mod 751)
x ≡ 861 × 445-1 (mod 107) ≡ 861 × 63 (mod 107) ≡ 101 (mod 107)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 691 × 751 × 107 = 55526687
  2. We calculate the numbers M1 to M3
    M1=M/m1=55526687/691=80357,   M2=M/m2=55526687/751=73937,   M3=M/m3=55526687/107=518941
  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
    691803570691010
    80357691116201101
    69120138801-3
    201882251-37
    8825313-37-24
    25131127-2431
    131211-2431-55
    12112031-55691
    So our multiplicative inverse is -55 mod 691 ≡ 636
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    751739370751010
    7393775198339101
    75133927301-2
    339734471-29
    7347126-29-11
    47261219-1120
    262115-1120-31
    2154120-31144
    5150-31144-751
    So our multiplicative inverse is 144 mod 751 ≡ 144
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1075189410107010
    518941107484998101
    107981901-1
    9891081-111
    9811-111-12
    818011-12107
    So our multiplicative inverse is -12 mod 107 ≡ 95
    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
    =  (367 × 80357 × 636 +
       32 × 73937 × 144 +
       101 × 518941 × 95)   mod 55526687
    = 33173204 (mod 55526687)


    So our answer is 33173204 (mod 55526687).


Verification

So we found that x ≡ 33173204
If this is correct, then the following statements (i.e. the original equations) are true:
117x (mod 691) ≡ 97 (mod 691)
803x (mod 751) ≡ 162 (mod 751)
445x (mod 107) ≡ 861 (mod 107)

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