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
80518347301-4
183732371-49
7337136-49-13
3736119-1322
361360-1322-805
So our multiplicative inverse is 22 mod 805 ≡ 22
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5213714301-14
3731211-14169
3130-14169-521
So our multiplicative inverse is 169 mod 521 ≡ 169
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
607382122501-1
38222511571-12
225157168-12-3
157682212-38
682135-38-27
215418-27116
5150-27116-607
So our multiplicative inverse is 116 mod 607 ≡ 116
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 ≡ 478 × 183-1 (mod 805) ≡ 478 × 22 (mod 805) ≡ 51 (mod 805)
x ≡ 643 × 37-1 (mod 521) ≡ 643 × 169 (mod 521) ≡ 299 (mod 521)
x ≡ 255 × 382-1 (mod 607) ≡ 255 × 116 (mod 607) ≡ 444 (mod 607)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 805 × 521 × 607 = 254578835
  2. We calculate the numbers M1 to M3
    M1=M/m1=254578835/805=316247,   M2=M/m2=254578835/521=488635,   M3=M/m3=254578835/607=419405
  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
    8053162470805010
    316247805392687101
    805687111801-1
    6871185971-16
    11897121-16-7
    97214136-734
    211318-734-41
    1381534-4175
    8513-4175-116
    531275-116191
    3211-116191-307
    2120191-307805
    So our multiplicative inverse is -307 mod 805 ≡ 498
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5214886350521010
    488635521937458101
    52145816301-1
    458637171-18
    6317312-18-25
    1712158-2533
    12522-2533-91
    522133-91215
    2120-91215-521
    So our multiplicative inverse is 215 mod 521 ≡ 215
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6074194050607010
    419405607690575101
    60757513201-1
    5753217311-118
    323111-118-19
    31131018-19607
    So our multiplicative inverse is -19 mod 607 ≡ 588
    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
    =  (51 × 316247 × 498 +
       299 × 488635 × 215 +
       444 × 419405 × 588)   mod 254578835
    = 10225966 (mod 254578835)


    So our answer is 10225966 (mod 254578835).


Verification

So we found that x ≡ 10225966
If this is correct, then the following statements (i.e. the original equations) are true:
183x (mod 805) ≡ 478 (mod 805)
37x (mod 521) ≡ 643 (mod 521)
382x (mod 607) ≡ 255 (mod 607)

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