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
5218040521010
8045211283101
521283123801-1
2832381451-12
23845513-12-11
4513362-1135
13621-1135-81
616035-81521
So our multiplicative inverse is -81 mod 521 ≡ 440
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
88842523801-2
425381171-223
38753-223-117
732123-117257
3130-117257-888
So our multiplicative inverse is 257 mod 888 ≡ 257
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1517370151010
7371514133101
15113311801-1
13318771-18
18724-18-17
74138-1725
4311-1725-42
313025-42151
So our multiplicative inverse is -42 mod 151 ≡ 109
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 ≡ 542 × 804-1 (mod 521) ≡ 542 × 440 (mod 521) ≡ 383 (mod 521)
x ≡ 635 × 425-1 (mod 888) ≡ 635 × 257 (mod 888) ≡ 691 (mod 888)
x ≡ 49 × 737-1 (mod 151) ≡ 49 × 109 (mod 151) ≡ 56 (mod 151)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 521 × 888 × 151 = 69859848
  2. We calculate the numbers M1 to M3
    M1=M/m1=69859848/521=134088,   M2=M/m2=69859848/888=78671,   M3=M/m3=69859848/151=462648
  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
    5211340880521010
    134088521257191101
    521191213901-2
    1911391521-23
    13952235-23-8
    52351173-811
    351721-811-30
    17117011-30521
    So our multiplicative inverse is -30 mod 521 ≡ 491
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    888786710888010
    7867188888527101
    888527136101-1
    52736111661-12
    361166229-12-5
    166295212-527
    292118-527-32
    2182527-3291
    8513-3291-123
    531291-123214
    3211-123214-337
    2120214-337888
    So our multiplicative inverse is -337 mod 888 ≡ 551
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1514626480151010
    4626481513063135101
    15113511601-1
    13516871-19
    16722-19-19
    72319-1966
    2120-1966-151
    So our multiplicative inverse is 66 mod 151 ≡ 66
    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
    =  (383 × 134088 × 491 +
       691 × 78671 × 551 +
       56 × 462648 × 66)   mod 69859848
    = 12956611 (mod 69859848)


    So our answer is 12956611 (mod 69859848).


Verification

So we found that x ≡ 12956611
If this is correct, then the following statements (i.e. the original equations) are true:
804x (mod 521) ≡ 542 (mod 521)
425x (mod 888) ≡ 635 (mod 888)
737x (mod 151) ≡ 49 (mod 151)

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