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
707520118701-1
52018721461-13
187146141-13-4
146413233-415
4123118-415-19
23181515-1934
18533-1934-121
531234-121155
3211-121155-276
2120155-276707
So our multiplicative inverse is -276 mod 707 ≡ 431
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3555130355010
5133551158101
35515823901-2
15839421-29
392191-29-173
21209-173355
So our multiplicative inverse is -173 mod 355 ≡ 182
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5125970512010
597512185101
512856201-6
8524211-6253
2120-6253-512
So our multiplicative inverse is 253 mod 512 ≡ 253
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 ≡ 899 × 520-1 (mod 707) ≡ 899 × 431 (mod 707) ≡ 33 (mod 707)
x ≡ 803 × 513-1 (mod 355) ≡ 803 × 182 (mod 355) ≡ 241 (mod 355)
x ≡ 426 × 597-1 (mod 512) ≡ 426 × 253 (mod 512) ≡ 258 (mod 512)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 707 × 355 × 512 = 128504320
  2. We calculate the numbers M1 to M3
    M1=M/m1=128504320/707=181760,   M2=M/m2=128504320/355=361984,   M3=M/m3=128504320/512=250985
  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
    7071817600707010
    18176070725761101
    70761113601-11
    61361251-1112
    3625111-1112-23
    25112312-2358
    11332-2358-197
    321158-197255
    2120-197255-707
    So our multiplicative inverse is 255 mod 707 ≡ 255
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3553619840355010
    3619843551019239101
    355239111601-1
    239116271-13
    1167164-13-49
    74133-4952
    4311-4952-101
    313052-101355
    So our multiplicative inverse is -101 mod 355 ≡ 254
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5122509850512010
    250985512490105101
    51210549201-4
    105921131-45
    921371-45-39
    1311305-39512
    So our multiplicative inverse is -39 mod 512 ≡ 473
    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
    =  (33 × 181760 × 255 +
       241 × 361984 × 254 +
       258 × 250985 × 473)   mod 128504320
    = 87879426 (mod 128504320)


    So our answer is 87879426 (mod 128504320).


Verification

So we found that x ≡ 87879426
If this is correct, then the following statements (i.e. the original equations) are true:
520x (mod 707) ≡ 899 (mod 707)
513x (mod 355) ≡ 803 (mod 355)
597x (mod 512) ≡ 426 (mod 512)

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