0

Suppose we are trying to find the smallest positive integers, $x,y$ such that, $$a + bx = cy$$ $$a \gt 0, b \gt a, c \gt b$$

If $a=0$, then this is just finding the lcm of $b$ and $c$. Not sure how to find this efficiently though with an offset. Is there some algorithm from modular arithmetic related to this?

Edit: I realized that this is a linear diophantine equestion.

Bill Dubuque
  • 272,048
Jeff
  • 853

1 Answers1

1
  • By dividing through by $\gcd(b,c)$, we may assume that $\gcd(b,c)=1$. (If $\gcd(b,c)$ doesn't divide $a$ then there are no solutions.)
  • Choose some $x_0$ such that $a+bx_0\equiv0\pmod c$, that is, some $x_0 \equiv -ab^{-1}\pmod c$.
  • Set $y_0 = (a+bx_0)/c$, so that $(x_0,y_0)$ is a solution.
  • Then all solutions are of the form $(x,y)=(x_0+kc,y_0+kb)$. In particular, one can find the smallest positive solution from this parametrization.
Greg Martin
  • 78,820