I'm trying to solve this general problem(to solve the programming one).
We have assigned variables $a$, $b$ and $n$. What is the least positive $x$, so that $a + bx$ is divisible by $n$?
It is guaranteed that $x$ exists.
So far, I have found no relations between modulo or GCD. The main trouble are the independant variables.