Solving system of equations using Chinese remainder theorem

98 Views Asked by At

I have a system of equations on that I would like to solve programatically:

$(x + a_1) \bmod b_1 = 0$

$(x + a_2) \bmod b_2 = 0$

$...$

$(x + a_i) \bmod b_i = 0$

$a$ and $b$ are given, and I would like to find the smallest positive solution for $x$. The numbers are too big to iterate through all possible solutions. I think it should be possible to solve it using the Chinese remainder theorem, but I haven't been able to get from one to the other. How can I translate this problem into a problem that can be solved using the CRT?

1

There are 1 best solutions below

0
On BEST ANSWER

Your system of equations is the same as solving $x\equiv -a_i \pmod{b_i}$.