0

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?

unbeli
  • 109
  • Looks like if all of a,b,m have the same gcd, I can divide all of them by it and make it work. But I'm not sure I understand what I'm doing, would appreciate an explanation. – unbeli Dec 09 '23 at 00:39
  • See the linked dupes for how to solve the congruence $,bx\equiv a\pmod{m}\ \ $ – Bill Dubuque Dec 09 '23 at 00:55

0 Answers0