1

I am having trouble comprehending the following problem:

In mod $n$ arithmetic, the quotient of two numbers $r$ and $m$ is a number $q$ such that $mq = r$ mod $n$. (The author mentioned before that he represents $\equiv$ with $=$). Given $r$, $m$, and $n$, how can you find $q$? How many $q$'s are there? Under what conditions is $q$ unique? [Hint: $mq = r$ mod $n$ iff there is an integer $k$ such that $qm + kn = r$. Divide by gcd($m$, $n$).

To find $q$, I think we need to first calculate gcd($m$, $n$) and then perform extended Euclid algorithm.

I'm not sure about the second question regarding how many $q$'s there are.

For the third question, I think $q$ is only unique if $m$ and $n$ are relatively prime.

I scoured the textbook for some hint, but I just have trouble understanding and I am not confident in my answers. A clear explanation of the problem and/or solutions is much appreciated.

mrQWERTY
  • 595

1 Answers1

1

For the first question, what you need is the Extended Euclidean Algorithm. One implementation is described in this answer.

Your idea about dividing by $\gcd(m,n)$ is right on the mark. If we do, then we get $$ \frac{m}{\gcd(m,n)}q\equiv\frac{r}{\gcd(m,n)}\quad\text{mod}\left(\frac{n}{\gcd(m,n)}\right) $$ For the second question, Bezout's Identity says that infinitely many $q$ exist if $\gcd(m,n)\mid r$. Otherwise, no $q$ exist.

For the third question, Bezout's Identity also guarantee's that $q$ is unique mod $\frac{n}{\gcd(m,n)}$.

robjohn
  • 345,667
  • Hello, I understand the first two points, however I am confused on the third point. I've read on several sites, but cannot find any sources that justifies that q is unique. – mrQWERTY Mar 12 '15 at 21:26
  • @Froggy: suppose we have two solutions $q_1$ and $q_2$. Then we must have $$\frac{m}{\gcd(m,n)}(q_1-q_2)\equiv0 \quad\text{mod}\left(\frac{n}{\gcd(m,n)}\right)$$ Since $\frac{m}{\gcd(m,n)}$ and $\frac{n}{\gcd(m,n)}$ are relatively prime, this means that $$q_1\equiv q_2\quad\text{mod}\left(\frac{n}{\gcd(m,n)}\right)$$ – robjohn Mar 12 '15 at 21:31