Expii

Solving Linear Congruence ax ≡ b (mod N) - Expii

To solve a linear congruence ax ≡ b (mod N), you can multiply by the inverse of a if gcd(a,N) = 1; otherwise, more care is needed, and there will either be no solutions or several (exactly gcd(a,N) total) solutions for x mod N.