Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I express $((a-b)/c) \bmod m$ in terms of $a \bmod m$, $b \bmod m$ and $c \bmod m$?

share|cite|improve this question
up vote 1 down vote accepted

Assuming the division is without remainder and that $c$ is relatively prime to $m$, you can just evaluate $(a-b)c^{-1}$ in $\mathbf Z/m\mathbf Z$. If $c$ is not relatively prime with $m$, you cannot deduce the value of $(a-b)/c$ modulo $m$ from the images of $a,b,c$ in $\mathbf Z/m\mathbf Z$ alone.

share|cite|improve this answer
if c is 2 and m is 10^9 + 7, then can I express that in a simple form? Also, what is meant by evaluating in Z/mZ? – Jatin Feb 2 '13 at 8:18
Since that $m$ is odd, it is relatively prime with $2$, and by inspection the inverse of $2$ modulo $m$ is $2^{-1}=5\times10^8+4\in \mathbf Z/m\mathbf Z$. Evaluation in $\mathbf Z/m\mathbf Z$ means computing modulo $m$, so in this case the result is $(500000004\times((a\bmod m)-(b\bmod m)) \bmod m$. – Marc van Leeuwen Feb 2 '13 at 11:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.