Sign up ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

1 Answer 1

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.