I have a problem.
I looking solution of the equation $a + b \cdot k \equiv 0 \pmod{n}$ for given values $a$, $b$ and $n$ (we are looking for value $k$). $k$ is positive integer.
How can we calculate it quickly?
For example:
$a = 10554$, $b = 6370$ and $n = 16383$
Solutions:
$10554 + 6370 \cdot 2025 \equiv 0 \pmod{16383}$
$10554 + 6370 \cdot 18408 \equiv 0 \pmod{16383}$
$10554 + 6370 \cdot 34791 \equiv 0 \pmod{16383}$
$10554 + 6370 \cdot 51174 \equiv 0 \pmod{16383}$
...
General: $k = 2025 + 16383 \cdot k_2$
When solutions do not exist?


If $\gcd(b,n) = 1$, then we are guaranteed a solution, as the inverse of $b$ modulo $n$ exists. In general if $\gcd(b,n) \mid a$ then we are guaranteed a solution too, as we can get rid of the $\gcd(b,n)$ factor. Indeed the later condition is necessary too, as then $nm - bk=a$ and so $\gcd(b,n) \mid a$.
To find solutions you might use the Extended Euclidean Algorithm. It's pretty easy application and just some basica algebra.