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
507131311401-3
1311141171-34
11417612-34-27
1712154-2731
12522-2731-89
522131-89209
2120-89209-507
So our multiplicative inverse is 209 mod 507 ≡ 209
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
25117317801-1
173782171-13
7817410-13-13
1710173-1316
10713-1316-29
732116-2974
3130-2974-251
So our multiplicative inverse is 74 mod 251 ≡ 74
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6557730655010
7736551118101
65511856501-5
118651531-56
6553112-56-11
5312456-1150
12522-1150-111
522150-111272
2120-111272-655
So our multiplicative inverse is 272 mod 655 ≡ 272
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 ≡ 933 × 131-1 (mod 507) ≡ 933 × 209 (mod 507) ≡ 309 (mod 507)
x ≡ 233 × 173-1 (mod 251) ≡ 233 × 74 (mod 251) ≡ 174 (mod 251)
x ≡ 339 × 773-1 (mod 655) ≡ 339 × 272 (mod 655) ≡ 508 (mod 655)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 507 × 251 × 655 = 83353335
  2. We calculate the numbers M1 to M3
    M1=M/m1=83353335/507=164405,   M2=M/m2=83353335/251=332085,   M3=M/m3=83353335/655=127257
  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
    5071644050507010
    164405507324137101
    50713739601-3
    137961411-34
    9641214-34-11
    41142134-1126
    141311-1126-37
    13113026-37507
    So our multiplicative inverse is -37 mod 507 ≡ 470
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2513320850251010
    332085251132312101
    25112201101-20
    1211111-2021
    111110-2021-251
    So our multiplicative inverse is 21 mod 251 ≡ 21
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6551272570655010
    127257655194187101
    65518739401-3
    187941931-34
    949311-34-7
    9319304-7655
    So our multiplicative inverse is -7 mod 655 ≡ 648
    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
    =  (309 × 164405 × 470 +
       174 × 332085 × 21 +
       508 × 127257 × 648)   mod 83353335
    = 48217023 (mod 83353335)


    So our answer is 48217023 (mod 83353335).


Verification

So we found that x ≡ 48217023
If this is correct, then the following statements (i.e. the original equations) are true:
131x (mod 507) ≡ 933 (mod 507)
173x (mod 251) ≡ 233 (mod 251)
773x (mod 655) ≡ 339 (mod 655)

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