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
5757770575010
7775751202101
575202217101-2
2021711311-23
17131516-23-17
31161153-1720
161511-1720-37
15115020-37575
So our multiplicative inverse is -37 mod 575 ≡ 538
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3316400331010
6403311309101
33130912201-1
309221411-115
221220-115-331
So our multiplicative inverse is 15 mod 331 ≡ 15
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3498720349010
8723492174101
3491742101-2
174117401-2349
So our multiplicative inverse is -2 mod 349 ≡ 347
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 ≡ 547 × 777-1 (mod 575) ≡ 547 × 538 (mod 575) ≡ 461 (mod 575)
x ≡ 949 × 640-1 (mod 331) ≡ 949 × 15 (mod 331) ≡ 2 (mod 331)
x ≡ 493 × 872-1 (mod 349) ≡ 493 × 347 (mod 349) ≡ 61 (mod 349)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 575 × 331 × 349 = 66423425
  2. We calculate the numbers M1 to M3
    M1=M/m1=66423425/575=115519,   M2=M/m2=66423425/331=200675,   M3=M/m3=66423425/349=190325
  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
    5751155190575010
    115519575200519101
    57551915601-1
    519569151-110
    5615311-110-31
    15111410-3141
    11423-3141-113
    431141-113154
    3130-113154-575
    So our multiplicative inverse is 154 mod 575 ≡ 154
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3312006750331010
    20067533160689101
    3318936401-3
    89641251-34
    6425214-34-11
    25141114-1115
    141113-1115-26
    1133215-2693
    3211-2693-119
    212093-119331
    So our multiplicative inverse is -119 mod 331 ≡ 212
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3491903250349010
    190325349545120101
    349120210901-2
    1201091111-23
    10911910-23-29
    1110113-2932
    101100-2932-349
    So our multiplicative inverse is 32 mod 349 ≡ 32
    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
    =  (461 × 115519 × 154 +
       2 × 200675 × 212 +
       61 × 190325 × 32)   mod 66423425
    = 22711236 (mod 66423425)


    So our answer is 22711236 (mod 66423425).


Verification

So we found that x ≡ 22711236
If this is correct, then the following statements (i.e. the original equations) are true:
777x (mod 575) ≡ 547 (mod 575)
640x (mod 331) ≡ 949 (mod 331)
872x (mod 349) ≡ 493 (mod 349)

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