This is a linear Diophantine equation. Its solution is very well known. It can be rewritten in the form ex + fy = d
. Find g = gcd(e, f)
. If d = g
then there are infinitely many integral solutions, and these can be found using the extended Euclidean algorithm. Consequently, if d
is merely a multiple of g
, there are infinitely many solutions as well. If d
is not a multiple of g
, there are no solutions.
↧
Answer by jason for How to create a function to solve two unknowns
↧