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
5037300503010
7305031227101
50322724901-2
227494311-29
4931118-29-11
31181139-1120
181315-1120-31
1352320-3182
5312-3182-113
321182-113195
2120-113195-503
So our multiplicative inverse is 195 mod 503 ≡ 195
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
491287120401-1
2872041831-12
20483238-12-5
8338272-512
38753-512-65
732112-65142
3130-65142-491
So our multiplicative inverse is 142 mod 491 ≡ 142
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
95315562301-6
155236171-637
231716-637-43
1762537-43123
6511-43123-166
5150123-166953
So our multiplicative inverse is -166 mod 953 ≡ 787
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 ≡ 732 × 730-1 (mod 503) ≡ 732 × 195 (mod 503) ≡ 391 (mod 503)
x ≡ 498 × 287-1 (mod 491) ≡ 498 × 142 (mod 491) ≡ 12 (mod 491)
x ≡ 111 × 155-1 (mod 953) ≡ 111 × 787 (mod 953) ≡ 634 (mod 953)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 503 × 491 × 953 = 235365269
  2. We calculate the numbers M1 to M3
    M1=M/m1=235365269/503=467923,   M2=M/m2=235365269/491=479359,   M3=M/m3=235365269/953=246973
  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
    5034679230503010
    467923503930133101
    503133310401-3
    1331041291-34
    10429317-34-15
    29171124-1519
    171215-1519-34
    1252219-3487
    5221-3487-208
    212087-208503
    So our multiplicative inverse is -208 mod 503 ≡ 295
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4914793590491010
    479359491976143101
    49114336201-3
    143622191-37
    621935-37-24
    195347-2479
    5411-2479-103
    414079-103491
    So our multiplicative inverse is -103 mod 491 ≡ 388
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9532469730953010
    246973953259146101
    95314667701-6
    146771691-67
    776918-67-13
    698857-13111
    8513-13111-124
    5312111-124235
    3211-124235-359
    2120235-359953
    So our multiplicative inverse is -359 mod 953 ≡ 594
    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
    =  (391 × 467923 × 295 +
       12 × 479359 × 388 +
       634 × 246973 × 594)   mod 235365269
    = 227302570 (mod 235365269)


    So our answer is 227302570 (mod 235365269).


Verification

So we found that x ≡ 227302570
If this is correct, then the following statements (i.e. the original equations) are true:
730x (mod 503) ≡ 732 (mod 503)
287x (mod 491) ≡ 498 (mod 491)
155x (mod 953) ≡ 111 (mod 953)

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