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
53839053010
839531544101
53441901-1
449481-15
9811-15-6
81805-653
So our multiplicative inverse is -6 mod 53 ≡ 47
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3939160393010
9163932130101
3931303301-3
13034311-3130
3130-3130-393
So our multiplicative inverse is 130 mod 393 ≡ 130
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5156270515010
6275151112101
51511246701-4
112671451-45
6745122-45-9
4522215-923
221220-923-515
So our multiplicative inverse is 23 mod 515 ≡ 23
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 ≡ 568 × 839-1 (mod 53) ≡ 568 × 47 (mod 53) ≡ 37 (mod 53)
x ≡ 627 × 916-1 (mod 393) ≡ 627 × 130 (mod 393) ≡ 159 (mod 393)
x ≡ 802 × 627-1 (mod 515) ≡ 802 × 23 (mod 515) ≡ 421 (mod 515)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 53 × 393 × 515 = 10726935
  2. We calculate the numbers M1 to M3
    M1=M/m1=10726935/53=202395,   M2=M/m2=10726935/393=27295,   M3=M/m3=10726935/515=20829
  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
    53202395053010
    20239553381841101
    534111201-1
    4112351-14
    12522-14-9
    52214-922
    2120-922-53
    So our multiplicative inverse is 22 mod 53 ≡ 22
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    393272950393010
    2729539369178101
    39317823701-2
    178374301-29
    373017-29-11
    307429-1153
    7231-1153-170
    212053-170393
    So our multiplicative inverse is -170 mod 393 ≡ 223
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    515208290515010
    2082951540229101
    51522925701-2
    22957411-29
    571570-29-515
    So our multiplicative inverse is 9 mod 515 ≡ 9
    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
    =  (37 × 202395 × 22 +
       159 × 27295 × 223 +
       421 × 20829 × 9)   mod 10726935
    = 10052706 (mod 10726935)


    So our answer is 10052706 (mod 10726935).


Verification

So we found that x ≡ 10052706
If this is correct, then the following statements (i.e. the original equations) are true:
839x (mod 53) ≡ 568 (mod 53)
916x (mod 393) ≡ 627 (mod 393)
627x (mod 515) ≡ 802 (mod 515)

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