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
763395136801-1
3953681271-12
368271317-12-27
27171102-2729
171017-2729-56
1071329-5685
7321-5685-226
313085-226763
So our multiplicative inverse is -226 mod 763 ≡ 537
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4033312701-12
337451-1249
7512-1249-61
522149-61171
2120-61171-403
So our multiplicative inverse is 171 mod 403 ≡ 171
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1518730151010
8731515118101
15111813301-1
118333191-14
3319114-14-5
1914154-59
14524-59-23
54119-2332
4140-2332-151
So our multiplicative inverse is 32 mod 151 ≡ 32
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 ≡ 420 × 395-1 (mod 763) ≡ 420 × 537 (mod 763) ≡ 455 (mod 763)
x ≡ 655 × 33-1 (mod 403) ≡ 655 × 171 (mod 403) ≡ 374 (mod 403)
x ≡ 750 × 873-1 (mod 151) ≡ 750 × 32 (mod 151) ≡ 142 (mod 151)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 763 × 403 × 151 = 46430839
  2. We calculate the numbers M1 to M3
    M1=M/m1=46430839/763=60853,   M2=M/m2=46430839/403=115213,   M3=M/m3=46430839/151=307489
  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
    763608530763010
    6085376379576101
    763576118701-1
    5761873151-14
    18715127-14-49
    157214-49102
    7170-49102-763
    So our multiplicative inverse is 102 mod 763 ≡ 102
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4031152130403010
    115213403285358101
    40335814501-1
    358457431-18
    454312-18-9
    4322118-9197
    2120-9197-403
    So our multiplicative inverse is 197 mod 403 ≡ 197
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1513074890151010
    307489151203653101
    1515324501-2
    5345181-23
    45855-23-17
    85133-1720
    5312-1720-37
    321120-3757
    2120-3757-151
    So our multiplicative inverse is 57 mod 151 ≡ 57
    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
    =  (455 × 60853 × 102 +
       374 × 115213 × 197 +
       142 × 307489 × 57)   mod 46430839
    = 11707927 (mod 46430839)


    So our answer is 11707927 (mod 46430839).


Verification

So we found that x ≡ 11707927
If this is correct, then the following statements (i.e. the original equations) are true:
395x (mod 763) ≡ 420 (mod 763)
33x (mod 403) ≡ 655 (mod 403)
873x (mod 151) ≡ 750 (mod 151)

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