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
989518147101-1
5184711471-12
47147101-12-21
4714702-21989
So our multiplicative inverse is -21 mod 989 ≡ 968
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
15221015010
221151411101
15111401-1
114231-13
4311-13-4
31303-415
So our multiplicative inverse is -4 mod 15 ≡ 11
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
823223315401-3
2231541691-34
15469216-34-11
6916454-1148
16531-1148-155
515048-155823
So our multiplicative inverse is -155 mod 823 ≡ 668
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 ≡ 781 × 518-1 (mod 989) ≡ 781 × 968 (mod 989) ≡ 412 (mod 989)
x ≡ 361 × 221-1 (mod 15) ≡ 361 × 11 (mod 15) ≡ 11 (mod 15)
x ≡ 285 × 223-1 (mod 823) ≡ 285 × 668 (mod 823) ≡ 267 (mod 823)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 989 × 15 × 823 = 12209205
  2. We calculate the numbers M1 to M3
    M1=M/m1=12209205/989=12345,   M2=M/m2=12209205/15=813947,   M3=M/m3=12209205/823=14835
  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
    989123450989010
    1234598912477101
    98947723501-2
    4773513221-227
    3522113-227-29
    22131927-2956
    13914-2956-85
    942156-85226
    4140-85226-989
    So our multiplicative inverse is 226 mod 989 ≡ 226
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    15813947015010
    81394715542632101
    1527101-7
    21201-715
    So our multiplicative inverse is -7 mod 15 ≡ 8
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    823148350823010
    148358231821101
    8232139401-39
    214511-39196
    4140-39196-823
    So our multiplicative inverse is 196 mod 823 ≡ 196
    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
    =  (412 × 12345 × 226 +
       11 × 813947 × 8 +
       267 × 14835 × 196)   mod 12209205
    = 7339781 (mod 12209205)


    So our answer is 7339781 (mod 12209205).


Verification

So we found that x ≡ 7339781
If this is correct, then the following statements (i.e. the original equations) are true:
518x (mod 989) ≡ 781 (mod 989)
221x (mod 15) ≡ 361 (mod 15)
223x (mod 823) ≡ 285 (mod 823)

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