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
95346322701-2
463271741-235
27463-235-212
431135-212247
3130-212247-953
So our multiplicative inverse is 247 mod 953 ≡ 247
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1999640199010
9641994168101
19916813101-1
168315131-16
311325-16-13
135236-1332
5312-1332-45
321132-4577
2120-4577-199
So our multiplicative inverse is 77 mod 199 ≡ 77
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5718220571010
8225711251101
57125126901-2
251693441-27
6944125-27-9
44251197-916
251916-916-25
1963116-2591
6160-2591-571
So our multiplicative inverse is 91 mod 571 ≡ 91
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 ≡ 377 × 463-1 (mod 953) ≡ 377 × 247 (mod 953) ≡ 678 (mod 953)
x ≡ 12 × 964-1 (mod 199) ≡ 12 × 77 (mod 199) ≡ 128 (mod 199)
x ≡ 857 × 822-1 (mod 571) ≡ 857 × 91 (mod 571) ≡ 331 (mod 571)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 953 × 199 × 571 = 108288437
  2. We calculate the numbers M1 to M3
    M1=M/m1=108288437/953=113629,   M2=M/m2=108288437/199=544163,   M3=M/m3=108288437/571=189647
  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
    9531136290953010
    113629953119222101
    95322246501-4
    222653271-413
    6527211-413-30
    27112513-3073
    11521-3073-176
    515073-176953
    So our multiplicative inverse is -176 mod 953 ≡ 777
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1995441630199010
    544163199273497101
    199972501-2
    9751921-239
    5221-239-80
    212039-80199
    So our multiplicative inverse is -80 mod 199 ≡ 119
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5711896470571010
    18964757133275101
    5717574601-7
    75461291-78
    4629117-78-15
    29171128-1523
    171215-1523-38
    1252223-3899
    5221-3899-236
    212099-236571
    So our multiplicative inverse is -236 mod 571 ≡ 335
    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
    =  (678 × 113629 × 777 +
       128 × 544163 × 119 +
       331 × 189647 × 335)   mod 108288437
    = 56753734 (mod 108288437)


    So our answer is 56753734 (mod 108288437).


Verification

So we found that x ≡ 56753734
If this is correct, then the following statements (i.e. the original equations) are true:
463x (mod 953) ≡ 377 (mod 953)
964x (mod 199) ≡ 12 (mod 199)
822x (mod 571) ≡ 857 (mod 571)

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