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

I'm solving an algorithm problem and it boils down to solving the congruency $$dp \equiv s \mod N$$ for the smalest value of $d$. Is there a way I can use number theory to solve this?

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

Your congruence will have a solution if and only if $\gcd(p,\ N)=g| s$ and there will be $g$ solutions modulo $N$.

The general solution is given by the extended Euclidean algorithm. See the linear congruence theorem and the extended Euclidean algorithm which outlines a method of solution.

share|cite|improve this answer

Your Answer


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