The equation is equivalent to xa + yn = b, and so,
in view of a previous algorithm, a
necessary and sufficient condition
for a solution to exist is that gcd(a,n) divides b.
Put d = gcd(a,n).
By a previous algorithm,
there is x'Z
such that all solutions (x,y) to
xa + yn = b satisfy
x = x'b/d-kn/d mod n for k =
0, ..., d - 1.
Thus, there are d different solutions.