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
521284123701-1
2842371471-12
2374752-12-11
4722312-11255
2120-11255-521
So our multiplicative inverse is 255 mod 521 ≡ 255
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
635507112801-1
50712831231-14
12812315-14-5
12352434-5124
5312-5124-129
3211124-129253
2120-129253-635
So our multiplicative inverse is 253 mod 635 ≡ 253
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
721198312701-3
1981271711-34
12771156-34-7
71561154-711
5615311-711-40
15111411-4051
11423-4051-142
431151-142193
3130-142193-721
So our multiplicative inverse is 193 mod 721 ≡ 193
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 ≡ 177 × 284-1 (mod 521) ≡ 177 × 255 (mod 521) ≡ 329 (mod 521)
x ≡ 408 × 507-1 (mod 635) ≡ 408 × 253 (mod 635) ≡ 354 (mod 635)
x ≡ 339 × 198-1 (mod 721) ≡ 339 × 193 (mod 721) ≡ 537 (mod 721)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 521 × 635 × 721 = 238532035
  2. We calculate the numbers M1 to M3
    M1=M/m1=238532035/521=457835,   M2=M/m2=238532035/635=375641,   M3=M/m3=238532035/721=330835
  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
    5214578350521010
    457835521878397101
    521397112401-1
    3971243251-14
    12425424-14-17
    2524114-1721
    241240-1721-521
    So our multiplicative inverse is 21 mod 521 ≡ 21
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6353756410635010
    375641635591356101
    635356127901-1
    3562791771-12
    27977348-12-7
    77481292-79
    4829119-79-16
    29191109-1625
    191019-1625-41
    1091125-4166
    9190-4166-635
    So our multiplicative inverse is 66 mod 635 ≡ 66
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7213308350721010
    330835721458617101
    721617110401-1
    6171045971-16
    1049717-16-7
    9771366-797
    7611-797-104
    616097-104721
    So our multiplicative inverse is -104 mod 721 ≡ 617
    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
    =  (329 × 457835 × 21 +
       354 × 375641 × 66 +
       537 × 330835 × 617)   mod 238532035
    = 142082239 (mod 238532035)


    So our answer is 142082239 (mod 238532035).


Verification

So we found that x ≡ 142082239
If this is correct, then the following statements (i.e. the original equations) are true:
284x (mod 521) ≡ 177 (mod 521)
507x (mod 635) ≡ 408 (mod 635)
198x (mod 721) ≡ 339 (mod 721)

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