Celeb Glow
general | April 10, 2026

How to find all integer solution of an equation?

$\begingroup$

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?

$\endgroup$ 6

1 Answer

$\begingroup$

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.

$\endgroup$

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy