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
70366713601-1
6673618191-119
3619117-119-20
19171219-2039
17281-2039-332
212039-332703
So our multiplicative inverse is -332 mod 703 ≡ 371
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2112190211010
21921118101
211826301-26
83221-2653
3211-2653-79
212053-79211
So our multiplicative inverse is -79 mod 211 ≡ 132
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
685504118101-1
50418121421-13
181142139-13-4
142393253-415
3925114-415-19
251411115-1934
141113-1934-53
1133234-53193
3211-53193-246
2120193-246685
So our multiplicative inverse is -246 mod 685 ≡ 439
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 ≡ 986 × 667-1 (mod 703) ≡ 986 × 371 (mod 703) ≡ 246 (mod 703)
x ≡ 62 × 219-1 (mod 211) ≡ 62 × 132 (mod 211) ≡ 166 (mod 211)
x ≡ 511 × 504-1 (mod 685) ≡ 511 × 439 (mod 685) ≡ 334 (mod 685)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 703 × 211 × 685 = 101608105
  2. We calculate the numbers M1 to M3
    M1=M/m1=101608105/703=144535,   M2=M/m2=101608105/211=481555,   M3=M/m3=101608105/685=148333
  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
    7031445350703010
    144535703205420101
    703420128301-1
    42028311371-12
    28313729-12-5
    13791522-577
    9241-577-313
    212077-313703
    So our multiplicative inverse is -313 mod 703 ≡ 390
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2114815550211010
    481555211228253101
    2115335201-3
    5352111-34
    521520-34-211
    So our multiplicative inverse is 4 mod 211 ≡ 4
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6851483330685010
    148333685216373101
    685373131201-1
    3733121611-12
    3126157-12-11
    617852-1190
    7512-1190-101
    522190-101292
    2120-101292-685
    So our multiplicative inverse is 292 mod 685 ≡ 292
    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
    =  (246 × 144535 × 390 +
       166 × 481555 × 4 +
       334 × 148333 × 292)   mod 101608105
    = 101183739 (mod 101608105)


    So our answer is 101183739 (mod 101608105).


Verification

So we found that x ≡ 101183739
If this is correct, then the following statements (i.e. the original equations) are true:
667x (mod 703) ≡ 986 (mod 703)
219x (mod 211) ≡ 62 (mod 211)
504x (mod 685) ≡ 511 (mod 685)

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