1

I have two equations $a \equiv bx\mod M$ and $c \equiv bx\mod N$ in which I know $a, b, c, M$, and $N$. I am trying to find $MN > x \geq 0$ ($x$ is non-negative). Further, $M$ and $N$ are odd and relatively prime (in my case $M$ and $N$ are odd primes). The solutions to each equations lie on a line with slopes $M$ (or $N$). These lines with different slopes intersect at exactly one point, from which I intend to get the value of $x$. Following is my attempt.

Given $a$ (or $c$), I do $$a + iM \text{ or } c + iN, i = 0, 1, 2, \cdots,$$ until $a + iM \mod b \equiv 0$ (or $c + iN \mod b \equiv 0$). Next, $$x_1 = \frac{a + iM}{b} \text{ and } x_2 = \frac{c + iN}{b}.$$ Then I extend the solution by performing $$x_1 + jM \text{ and } x_2 + kN, j=0, 1, 2, \cdots,$$ such that $x_1$ and $x_2$ are both less than $MN$. I solve the two lines for their intersection.

This works but I wanted to know if there is an easier way to solve this system. I also want to know, if I am missing any solution by performing these operations and if my attempt is right. Thank you!

PS: My question is different from the one here where the equation is of the form $ax \equiv b \mod M$ whereas in my question it is of the form $a \equiv bx \mod M$.

learner
  • 685
  • Divide by $\gcd(b,M)$ and $\gcd(b,N)$ to reduce the equivalences and find the inverses of $\frac {b}{\gcd}$. If $b$ and $M|N$ are not relatively prime there will be multiple solutions – fleablood Dec 10 '24 at 17:01
  • @fleablood, thank you for your response. I followed the first part of your comment, but could not get the second part. What do you mean by inverses of $\frac{b}{\gcd}$? Also since $M, N$ are prime and $b \neq M, N$, their gcd is always $1$ – learner Dec 10 '24 at 17:30
  • By here each congruence is solvable $!\iff! (b,M)\mid a,,$ and $,(b,N)\mid c,,$ resp. When so, cancelling the gcds then dividing they reduce to a system of the form $,x\equiv \bar a\pmod{! m},, x\equiv \bar c\pmod{!n},,$ with $(m,n)=1,,$ which is solvable using the common CRT formula. $\ \ $ – Bill Dubuque Dec 10 '24 at 18:44
  • For a solution-verification question to be on topic you must specify precisely which step in the proof you question, and why so. This site is not meant to be used as a proof checking machine. – Bill Dubuque Dec 10 '24 at 18:44
  • The standard way to solve it is as I described above. If anything remains unclear you are welcome to ask questions in comments in the linked dupes (or here if more appropriate). The site rules on SVs, dupes, etc are unfortunately compromises that are necessary to keep the site healthy. – Bill Dubuque Dec 10 '24 at 20:22
  • 1
    Oh, I missed that $M$ and $N$ were primes. But that makes it really easy! Every element of $b$ has a multiplicative inverse $\mod M$ where $b^{-1}\cdot b \equiv 1 \pmod M$. For example if $M = 17$ then $2^{-1} \equiv 9\pmod {17}$ because $2\times 9\equiv 1 \pmod {17}$. And $3^{-1}\equiv 6$ and $4^{-1}\equiv 13$ and $5^{-1}\equiv 7$ and so on. So $x \equiv b^{-1}a \pmod M$ and $x\equiv b^{-1}c\pmod N$. It's just if $M$ and $N$ aren't prime $b$ has an inverse only if $b$ is relatively prime. But if $b$ isn't then $\frac {b}{\gcd(b,M)}\mod \frac{M}{\gcd(b,M)}$ does. – fleablood Dec 11 '24 at 17:13

0 Answers0