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
743424131901-1
42431911051-12
31910534-12-7
10542612-7184
4140-7184-743
So our multiplicative inverse is 184 mod 743 ≡ 184
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3254173801-7
4138131-78
383122-78-103
32118-103111
2120-103111-325
So our multiplicative inverse is 111 mod 325 ≡ 111
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
659422123701-1
42223711851-12
237185152-12-3
185523292-311
5229123-311-14
29231611-1425
23635-1425-89
651125-89114
5150-89114-659
So our multiplicative inverse is 114 mod 659 ≡ 114
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 ≡ 597 × 424-1 (mod 743) ≡ 597 × 184 (mod 743) ≡ 627 (mod 743)
x ≡ 242 × 41-1 (mod 325) ≡ 242 × 111 (mod 325) ≡ 212 (mod 325)
x ≡ 923 × 422-1 (mod 659) ≡ 923 × 114 (mod 659) ≡ 441 (mod 659)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 743 × 325 × 659 = 159132025
  2. We calculate the numbers M1 to M3
    M1=M/m1=159132025/743=214175,   M2=M/m2=159132025/325=489637,   M3=M/m3=159132025/659=241475
  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
    7432141750743010
    214175743288191101
    743191317001-3
    1911701211-34
    1702182-34-35
    2121014-35354
    2120-35354-743
    So our multiplicative inverse is 354 mod 743 ≡ 354
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3254896370325010
    4896373251506187101
    325187113801-1
    1871381491-12
    13849240-12-5
    4940192-57
    40944-57-33
    94217-3373
    4140-3373-325
    So our multiplicative inverse is 73 mod 325 ≡ 73
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6592414750659010
    241475659366281101
    65928129701-2
    281972871-25
    9787110-25-7
    8710875-761
    10713-761-68
    732161-68197
    3130-68197-659
    So our multiplicative inverse is 197 mod 659 ≡ 197
    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
    =  (627 × 214175 × 354 +
       212 × 489637 × 73 +
       441 × 241475 × 197)   mod 159132025
    = 28992487 (mod 159132025)


    So our answer is 28992487 (mod 159132025).


Verification

So we found that x ≡ 28992487
If this is correct, then the following statements (i.e. the original equations) are true:
424x (mod 743) ≡ 597 (mod 743)
41x (mod 325) ≡ 242 (mod 325)
422x (mod 659) ≡ 923 (mod 659)

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