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
715548116701-1
5481673471-14
16747326-14-13
47261214-1317
262115-1317-30
2154117-30137
5150-30137-715
So our multiplicative inverse is 137 mod 715 ≡ 137
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
38110636301-3
106631431-34
6343120-34-7
4320234-718
20362-718-115
321118-115133
2120-115133-381
So our multiplicative inverse is 133 mod 381 ≡ 133
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2579970257010
9972573226101
25722613101-1
22631791-18
31934-18-25
94218-2558
4140-2558-257
So our multiplicative inverse is 58 mod 257 ≡ 58
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 ≡ 414 × 548-1 (mod 715) ≡ 414 × 137 (mod 715) ≡ 233 (mod 715)
x ≡ 98 × 106-1 (mod 381) ≡ 98 × 133 (mod 381) ≡ 80 (mod 381)
x ≡ 481 × 997-1 (mod 257) ≡ 481 × 58 (mod 257) ≡ 142 (mod 257)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 715 × 381 × 257 = 70010655
  2. We calculate the numbers M1 to M3
    M1=M/m1=70010655/715=97917,   M2=M/m2=70010655/381=183755,   M3=M/m3=70010655/257=272415
  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
    715979170715010
    97917715136677101
    71567713801-1
    6773817311-118
    383117-118-19
    3174318-1994
    7321-1994-207
    313094-207715
    So our multiplicative inverse is -207 mod 715 ≡ 508
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3811837550381010
    183755381482113101
    38111334201-3
    113422291-37
    4229113-37-10
    2913237-1027
    13341-1027-118
    313027-118381
    So our multiplicative inverse is -118 mod 381 ≡ 263
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2572724150257010
    2724152571059252101
    2572521501-1
    25255021-151
    5221-151-103
    212051-103257
    So our multiplicative inverse is -103 mod 257 ≡ 154
    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
    =  (233 × 97917 × 508 +
       80 × 183755 × 263 +
       142 × 272415 × 154)   mod 70010655
    = 59974433 (mod 70010655)


    So our answer is 59974433 (mod 70010655).


Verification

So we found that x ≡ 59974433
If this is correct, then the following statements (i.e. the original equations) are true:
548x (mod 715) ≡ 414 (mod 715)
106x (mod 381) ≡ 98 (mod 381)
997x (mod 257) ≡ 481 (mod 257)

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