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
6298275501-7
82551271-78
552721-78-23
2712708-23629
So our multiplicative inverse is -23 mod 629 ≡ 606
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
802495130701-1
49530711881-12
3071881119-12-3
1881191692-35
11969150-35-8
69501195-813
5019212-813-34
19121713-3447
12715-3447-81
751247-81128
5221-81128-337
2120128-337802
So our multiplicative inverse is -337 mod 802 ≡ 465
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1134090113010
409113370101
1137014301-1
70431271-12
4327116-12-3
27161112-35
161115-35-8
115215-821
5150-821-113
So our multiplicative inverse is 21 mod 113 ≡ 21
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 ≡ 423 × 82-1 (mod 629) ≡ 423 × 606 (mod 629) ≡ 335 (mod 629)
x ≡ 962 × 495-1 (mod 802) ≡ 962 × 465 (mod 802) ≡ 616 (mod 802)
x ≡ 403 × 409-1 (mod 113) ≡ 403 × 21 (mod 113) ≡ 101 (mod 113)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 629 × 802 × 113 = 57003754
  2. We calculate the numbers M1 to M3
    M1=M/m1=57003754/629=90626,   M2=M/m2=57003754/802=71077,   M3=M/m3=57003754/113=504458
  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
    629906260629010
    9062662914450101
    62950122901-12
    50291211-1213
    292118-1213-25
    2182513-2563
    8513-2563-88
    531263-88151
    3211-88151-239
    2120151-239629
    So our multiplicative inverse is -239 mod 629 ≡ 390
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    802710770802010
    7107780288501101
    802501130101-1
    50130112001-12
    3012001101-12-3
    2001011992-35
    1019912-35-8
    9924915-8397
    2120-8397-802
    So our multiplicative inverse is 397 mod 802 ≡ 397
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1135044580113010
    504458113446426101
    113264901-4
    269281-49
    9811-49-13
    81809-13113
    So our multiplicative inverse is -13 mod 113 ≡ 100
    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
    =  (335 × 90626 × 390 +
       616 × 71077 × 397 +
       101 × 504458 × 100)   mod 57003754
    = 1075296 (mod 57003754)


    So our answer is 1075296 (mod 57003754).


Verification

So we found that x ≡ 1075296
If this is correct, then the following statements (i.e. the original equations) are true:
82x (mod 629) ≡ 423 (mod 629)
495x (mod 802) ≡ 962 (mod 802)
409x (mod 113) ≡ 403 (mod 113)

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