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
31751031010
75131247101
3174301-4
73211-49
3130-49-31
So our multiplicative inverse is 9 mod 31 ≡ 9
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1638390163010
839163524101
1632461901-6
2419151-67
19534-67-27
54117-2734
4140-2734-163
So our multiplicative inverse is 34 mod 163 ≡ 34
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
709562114701-1
56214731211-14
147121126-14-5
121264174-524
261719-524-29
1791824-2953
9811-2953-82
818053-82709
So our multiplicative inverse is -82 mod 709 ≡ 627
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 ≡ 724 × 751-1 (mod 31) ≡ 724 × 9 (mod 31) ≡ 6 (mod 31)
x ≡ 569 × 839-1 (mod 163) ≡ 569 × 34 (mod 163) ≡ 112 (mod 163)
x ≡ 760 × 562-1 (mod 709) ≡ 760 × 627 (mod 709) ≡ 72 (mod 709)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 31 × 163 × 709 = 3582577
  2. We calculate the numbers M1 to M3
    M1=M/m1=3582577/31=115567,   M2=M/m2=3582577/163=21979,   M3=M/m3=3582577/709=5053
  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
    31115567031010
    11556731372730101
    31301101-1
    3013001-131
    So our multiplicative inverse is -1 mod 31 ≡ 30
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    163219790163010
    21979163134137101
    16313712601-1
    13726571-16
    26735-16-19
    75126-1925
    5221-1925-69
    212025-69163
    So our multiplicative inverse is -69 mod 163 ≡ 94
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    70950530709010
    5053709790101
    7099077901-7
    90791111-78
    791172-78-63
    112518-63323
    2120-63323-709
    So our multiplicative inverse is 323 mod 709 ≡ 323
    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
    =  (6 × 115567 × 30 +
       112 × 21979 × 94 +
       72 × 5053 × 323)   mod 3582577
    = 704109 (mod 3582577)


    So our answer is 704109 (mod 3582577).


Verification

So we found that x ≡ 704109
If this is correct, then the following statements (i.e. the original equations) are true:
751x (mod 31) ≡ 724 (mod 31)
839x (mod 163) ≡ 569 (mod 163)
562x (mod 709) ≡ 760 (mod 709)

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