How to solve simple Diophantine equation coming from solutions in modulos.

33 Views Asked by At

Given $x,y,z$ and knowing that all variables are integers, how could one uniquely solve:

$$xa-yb = z$$ ($\text{mod}\; xy$, of course).

I came across this when trying to solve a modulo question on a competition and I realized I always just guessed when I had the answer down to that form and it worked.

1

There are 1 best solutions below

1
On

Apply the extended Euclidean Algorithm; see Wikipedia

First solve ax + by = d where d is the GCD, then multiply by z/d to get the solutions to ax + by = z.