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
6418580641010
8586411217101
641217220701-2
2172071101-23
20710207-23-62
107133-6265
7321-6265-192
313065-192641
So our multiplicative inverse is -192 mod 641 ≡ 449
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2575360257010
536257222101
25722111501-11
2215171-1112
15721-1112-35
717012-35257
So our multiplicative inverse is -35 mod 257 ≡ 222
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6537610653010
7616531108101
6531086501-6
10852131-6127
5312-6127-133
3211127-133260
2120-133260-653
So our multiplicative inverse is 260 mod 653 ≡ 260
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 ≡ 829 × 858-1 (mod 641) ≡ 829 × 449 (mod 641) ≡ 441 (mod 641)
x ≡ 113 × 536-1 (mod 257) ≡ 113 × 222 (mod 257) ≡ 157 (mod 257)
x ≡ 686 × 761-1 (mod 653) ≡ 686 × 260 (mod 653) ≡ 91 (mod 653)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 641 × 257 × 653 = 107573261
  2. We calculate the numbers M1 to M3
    M1=M/m1=107573261/641=167821,   M2=M/m2=107573261/257=418573,   M3=M/m3=107573261/653=164737
  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
    6411678210641010
    167821641261520101
    641520112101-1
    5201214361-15
    12136313-15-16
    36132105-1637
    131013-1637-53
    1033137-53196
    3130-53196-641
    So our multiplicative inverse is 196 mod 641 ≡ 196
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2574185730257010
    4185732571628177101
    25717718001-1
    177802171-13
    8017412-13-13
    1712153-1316
    12522-1316-45
    522116-45106
    2120-45106-257
    So our multiplicative inverse is 106 mod 257 ≡ 106
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6531647370653010
    164737653252181101
    653181311001-3
    1811101711-34
    11071139-34-7
    71391324-711
    393217-711-18
    3274411-1883
    7413-1883-101
    431183-101184
    3130-101184-653
    So our multiplicative inverse is 184 mod 653 ≡ 184
    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
    =  (441 × 167821 × 196 +
       157 × 418573 × 106 +
       91 × 164737 × 184)   mod 107573261
    = 26040425 (mod 107573261)


    So our answer is 26040425 (mod 107573261).


Verification

So we found that x ≡ 26040425
If this is correct, then the following statements (i.e. the original equations) are true:
858x (mod 641) ≡ 829 (mod 641)
536x (mod 257) ≡ 113 (mod 257)
761x (mod 653) ≡ 686 (mod 653)

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