Diophantine Equation Generator
An equation like 6x + 15y = 21, where x and y must be whole numbers. Unlike a normal linear equation it may have no solution at all, and there is a clean test for which: solutions exist exactly when the greatest common divisor of the two coefficients divides the constant. This generates both cases on request, and where solutions exist it shows a run of them side by side, so the fixed step between one solution and the next is something you can read off rather than take on trust.
What this generator does
Draws two coefficients, then chooses the constant to make the equation either solvable or unsolvable as you asked. Where solutions exist it finds one with the extended Euclidean algorithm, lists the five nearest members of the family around it, and works out the smallest solution whose x is not negative.
How to use this tool
- Choose how large the coefficients may be.
- Decide whether you want a solvable equation or an impossible one.
- Test solvability with the divisibility rule before searching.
- Reveal the answer, and read the step between consecutive solutions off the table.
Understanding the controls
- Largest number
- How big the two coefficients may be, up to 200.
- Want a solvable one
- On, the constant is a multiple of the coefficients' greatest common divisor, so integer solutions exist. Off, it deliberately is not.
- Seed
- Reproduces the same equation exactly, so the solvable and unsolvable cases can be set side by side.
- Show the answer
- Reveals the base solution, a table of neighbouring solutions with the parameter t beside each, and the smallest one whose x is not negative — or states plainly that none exists.
Common use cases
- Practice at the solvability test before attempting a solution
- Showing that an equation can be perfectly ordinary and still have no integer answer
- Extended Euclidean algorithm exercises with verified answers
- Coin and measuring puzzles in their algebraic form
- Reproducing the same equation from a seed
How this generator works
The extended Euclidean algorithm produces x and y with ax + by = gcd(a, b), and multiplying both by the constant divided by that gcd solves the original. From there every solution is x + (b/g)t and y − (a/g)t, so the table is that formula evaluated at t from −2 to 2 — the step between consecutive rows is the content of the topic, and one pair on screen hides it. The smallest solution with x not negative is computed from the same formula rather than searched for. The check substitutes every listed solution back into the equation, because an evenly spaced table with the wrong step is still evenly spaced.
Randomness and fairness
The coefficients are random; solvability is decided by the divisibility rule, not by chance. Seeded equations reproduce exactly and are therefore explicitly not cryptographically secure. Unseeded, the browser's cryptographically secure generator supplies them.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Two unknowns and degree one only — the famous non-linear Diophantine problems are a different world entirely.
- Five solutions either side of the base one are listed, out of infinitely many; the rest follow from the same step.
- Coefficients are positive, so sign-handling cases do not appear.
- Solutions can be large negative numbers, which is correct but sometimes surprising.
- Equations are not stored between visits.
Privacy and your data
Coefficients and solutions are computed in your browser. Nothing about the equation or your seed is transmitted.
Related generators
- GCD and LCM Question GeneratorHighest common factor and lowest common multiple questions with Euclid's algorithm written out and the product identity checked.
- Chinese Remainder Challenge GeneratorSystems of congruences with pairwise coprime moduli and the unique solution below their product, substituted back into every one.
- Modular Arithmetic Question GeneratorRemainders, modular powers by repeated squaring, and inverses that only exist when the values are coprime.
- Simultaneous Equations GeneratorPairs of linear equations built backwards from a whole-number solution, with the elimination worked out line by line.