How to find if there's exists an integer X that fullfil this equation

29 Views Asked by At

Given A, B, C & D and the equation :

(A*X + B)%D = C

I tried to move the modulo to the other side but I end up with 2 unknown variables.

1

There are 1 best solutions below

0
On BEST ANSWER

I assume you mean $$AX+B\equiv C\mod D$$ or$$AX\equiv C-B=B'\mod D$$let $$E=\gcd(A,B',D)$$ then the latter equation is equivalent to $${A\over E}X\equiv {B'\over E}\mod {{D\over E}}$$by redefining the variables, we finally obtain$$PX\equiv Q\mod R$$where $$\gcd(P,Q,R)=1$$ note that $\gcd(P,R)=1$ (a proof is easy by definition of $\gcd$) therefore if $X_0$ is a particular solution, i.e. $PX_0\equiv Q\mod R$ then all the solutions are of the form $$X=Ru+X_0\quad,\quad u\in \Bbb Z$$