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
51815934101-3
159413361-310
413615-310-13
3657110-13101
5150-13101-518
So our multiplicative inverse is 101 mod 518 ≡ 101
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
60734172901-17
3429151-1718
29554-1718-107
541118-107125
4140-107125-607
So our multiplicative inverse is 125 mod 607 ≡ 125
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
757556120101-1
55620121541-13
201154147-13-4
154473133-415
471338-415-49
1381515-4964
8513-4964-113
531264-113177
3211-113177-290
2120177-290757
So our multiplicative inverse is -290 mod 757 ≡ 467
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 ≡ 517 × 159-1 (mod 518) ≡ 517 × 101 (mod 518) ≡ 417 (mod 518)
x ≡ 461 × 34-1 (mod 607) ≡ 461 × 125 (mod 607) ≡ 567 (mod 607)
x ≡ 7 × 556-1 (mod 757) ≡ 7 × 467 (mod 757) ≡ 241 (mod 757)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 518 × 607 × 757 = 238020482
  2. We calculate the numbers M1 to M3
    M1=M/m1=238020482/518=459499,   M2=M/m2=238020482/607=392126,   M3=M/m3=238020482/757=314426
  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
    5184594990518010
    45949951888733101
    51833152301-15
    33231101-1516
    231023-1516-47
    1033116-47157
    3130-47157-518
    So our multiplicative inverse is 157 mod 518 ≡ 157
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6073921260607010
    3921266076464101
    6074151301-151
    43111-151152
    3130-151152-607
    So our multiplicative inverse is 152 mod 607 ≡ 152
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7573144260757010
    314426757415271101
    757271221501-2
    2712151561-23
    21556347-23-11
    5647193-1114
    47952-1114-81
    924114-81338
    2120-81338-757
    So our multiplicative inverse is 338 mod 757 ≡ 338
    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
    =  (417 × 459499 × 157 +
       567 × 392126 × 152 +
       241 × 314426 × 338)   mod 238020482
    = 232759573 (mod 238020482)


    So our answer is 232759573 (mod 238020482).


Verification

So we found that x ≡ 232759573
If this is correct, then the following statements (i.e. the original equations) are true:
159x (mod 518) ≡ 517 (mod 518)
34x (mod 607) ≡ 461 (mod 607)
556x (mod 757) ≡ 7 (mod 757)

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