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
3895020389010
5023891113101
38911335001-3
113502131-37
5013311-37-24
1311127-2431
11251-2431-179
212031-179389
So our multiplicative inverse is -179 mod 389 ≡ 210
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
733568116501-1
5681653731-14
16573219-14-9
73193164-931
191613-931-40
1635131-40231
3130-40231-733
So our multiplicative inverse is 231 mod 733 ≡ 231
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
69964069010
964691367101
69671201-1
6723311-134
2120-134-69
So our multiplicative inverse is 34 mod 69 ≡ 34
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 ≡ 168 × 502-1 (mod 389) ≡ 168 × 210 (mod 389) ≡ 270 (mod 389)
x ≡ 567 × 568-1 (mod 733) ≡ 567 × 231 (mod 733) ≡ 503 (mod 733)
x ≡ 703 × 964-1 (mod 69) ≡ 703 × 34 (mod 69) ≡ 28 (mod 69)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 389 × 733 × 69 = 19674453
  2. We calculate the numbers M1 to M3
    M1=M/m1=19674453/389=50577,   M2=M/m2=19674453/733=26841,   M3=M/m3=19674453/69=285137
  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
    389505770389010
    505773891307101
    389755401-55
    74131-5556
    4311-5556-111
    313056-111389
    So our multiplicative inverse is -111 mod 389 ≡ 278
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    733268410733010
    2684173336453101
    733453128001-1
    45328011731-12
    2801731107-12-3
    1731071662-35
    10766141-35-8
    66411255-813
    4125116-813-21
    25161913-2134
    16917-2134-55
    971234-5589
    7231-5589-322
    212089-322733
    So our multiplicative inverse is -322 mod 733 ≡ 411
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    69285137069010
    28513769413229101
    692921101-2
    2911271-25
    11714-25-7
    74135-712
    4311-712-19
    313012-1969
    So our multiplicative inverse is -19 mod 69 ≡ 50
    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
    =  (270 × 50577 × 278 +
       503 × 26841 × 411 +
       28 × 285137 × 50)   mod 19674453
    = 5567638 (mod 19674453)


    So our answer is 5567638 (mod 19674453).


Verification

So we found that x ≡ 5567638
If this is correct, then the following statements (i.e. the original equations) are true:
502x (mod 389) ≡ 168 (mod 389)
568x (mod 733) ≡ 567 (mod 733)
964x (mod 69) ≡ 703 (mod 69)

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