You are on page 1of 1

1.

If you really want to solve that equation, maybe you could try something like
this:
The goal is to find the smallest possible y such that wx+dy=p.
We could first divide both w, d and p by gcd(w,d) then w and d become coprimes.
We take mod w and the equation becomes something like dy=p (mod w). Thus y=p�d-1
(mod w).
For coprimes, modular inverse always exists and could be found by extended
euclidean algorithm.

You might also like