I know this may seem like a math question but i just saw this in a contest and I really want to know how to solve it.
We have
a (mod c)
and
b (mod c)
and we’re looking for the value of the quotient
(a/b) (mod c)
Any ideas?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In the ring of integers modulo
C, these equations are equivalent:Thus you need to find
B-1, the multiplicative inverse ofBmoduloC. You can find it using e.g. extended Euclidian algorithm.Note that not every number has a multiplicative inverse for the given modulus.
Specifically,
B-1 exists if and only ifgcd(B, C) = 1(i.e.BandCare coprime).See also
Modular multiplicative inverse: Example
Suppose we want to find the multiplicative inverse of 3 modulo 11.
That is, we want to find
Using extended Euclidian algorithm, you will find that:
Thus, the modular multiplicative inverse of 3 modulo 11 is 4. In other words:
Naive algorithm: brute force search
One way to solve this:
Is to simply try
xfor all values0..11, and see if the equation holds true. For small modulus, this algorithm may be acceptable, but extended Euclidian algorithm is much better asymptotically.