How to find all integer solution of an equation?

13.5k Views Asked by At

I want to find whether a given equation like $2x + 5y = 27$ (tow variable linear equation) have integer solution for $x$ and $y$, $x\geq 0, y\geq 0$.

If yes how to find it?

And In my actual question i have to find a solution such that $x+y$ is minimized.

Is there a particular method for this or we have to check for all value?

1

There are 1 best solutions below

0
On

Try this link: How to find solutions of linear Diophantine ax + by = c? The mathematical answer to your question lies there, although I suspect it will be somewhat more complicated to efficiently implement this in code.