Let's imagine I have the following equation:
(x * b) % m == a
I know a, b and m and want to solve for x.
I know that if I could find the modular inverse of b (mod m), it's trivially solvable. In some cases however, modular inverse is not defined, but the equation has a solution.
For instance
a=11973
b=24253
m=18113
x=58
In this case, (x * b) % m == a
is true, but gcd(b, m) == 307
and therefore the inverse is not defined.
Is there a better way to solve such an equation?