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
2517110251010
7112512209101
25120914201-1
209424411-15
424111-15-6
4114105-6251
So our multiplicative inverse is -6 mod 251 ≡ 245
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
859485137401-1
48537411111-12
374111341-12-7
111412292-716
4129112-716-23
29122516-2362
12522-2362-147
522162-147356
2120-147356-859
So our multiplicative inverse is 356 mod 859 ≡ 356
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
38929819101-1
298913251-14
9125316-14-13
2516194-1317
16917-1317-30
971217-3047
7231-3047-171
212047-171389
So our multiplicative inverse is -171 mod 389 ≡ 218
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 ≡ 482 × 711-1 (mod 251) ≡ 482 × 245 (mod 251) ≡ 120 (mod 251)
x ≡ 692 × 485-1 (mod 859) ≡ 692 × 356 (mod 859) ≡ 678 (mod 859)
x ≡ 68 × 298-1 (mod 389) ≡ 68 × 218 (mod 389) ≡ 42 (mod 389)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 251 × 859 × 389 = 83871901
  2. We calculate the numbers M1 to M3
    M1=M/m1=83871901/251=334151,   M2=M/m2=83871901/859=97639,   M3=M/m3=83871901/389=215609
  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
    2513341510251010
    334151251133170101
    2517034101-3
    70411291-34
    4129112-34-7
    2912254-718
    12522-718-43
    522118-43104
    2120-43104-251
    So our multiplicative inverse is 104 mod 251 ≡ 104
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    859976390859010
    97639859113572101
    859572128701-1
    57228712851-12
    28728512-12-3
    285214212-3428
    2120-3428-859
    So our multiplicative inverse is 428 mod 859 ≡ 428
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3892156090389010
    215609389554103101
    38910338001-3
    103801231-34
    8023311-34-15
    2311214-1534
    111110-1534-389
    So our multiplicative inverse is 34 mod 389 ≡ 34
    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
    =  (120 × 334151 × 104 +
       678 × 97639 × 428 +
       42 × 215609 × 34)   mod 83871901
    = 17456417 (mod 83871901)


    So our answer is 17456417 (mod 83871901).


Verification

So we found that x ≡ 17456417
If this is correct, then the following statements (i.e. the original equations) are true:
711x (mod 251) ≡ 482 (mod 251)
485x (mod 859) ≡ 692 (mod 859)
298x (mod 389) ≡ 68 (mod 389)

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