Diophantine Equation Calculator
Solve linear Diophantine equations of the form ax + by = c. Find integer solutions using the Extended Euclidean Algorithm.
About this calculator
A linear Diophantine equation asks for whole-number solutions to ax + by = c, and whether any exist at all comes down to a single divisibility check: a solution exists exactly when the greatest common divisor of a and b divides c evenly, with no remainder. This calculator runs the Extended Euclidean Algorithm to compute that GCD and, in the same pass, two coefficients that express the GCD itself as a combination of a and b — a result called Bezout's identity. Those coefficients are then scaled by c divided by the GCD to produce one particular solution, x-naught and y-naught, that genuinely satisfies the original equation rather than an equation for the GCD alone.
Because a linear equation with integer solutions always has infinitely many of them, the calculator also reports the General Solution as a formula in a free parameter t: every integer value of t, positive, negative, or zero, produces another valid pair. At the default values of a = 3, b = 5, c = 1, the GCD of 3 and 5 is 1, which divides every integer including 1 itself, so a solution is guaranteed to exist before any arithmetic even starts. When a and b share a larger common factor that does not divide c, the calculator reports plainly that no integer solution exists — it does not fall back to showing the nearest approximate, non-integer answer, because none of the outputs here are meant to be read as anything but exact whole numbers.
Inputs
Results
Solution Exists
Yes
How to Use This Calculator
- Enter a, b, and c.
- Review the Solution Exists result.
- Use x₀ (particular) and y₀ (particular) to inform your decision.
- Use the chart to visualize the results and explore different scenarios by adjusting inputs.
What each input means
- a
- Coefficient a in ax + by = c
- b
- Coefficient b in ax + by = c
- c
- Right-hand side constant c in ax + by = c
How this is calculated
Worked example, using the default values
- Identify Input Parametersa = 3, b = 5, c = 1 = 3 input(s) provided
- Calculate Solution ExistsYes = Yes
- Calculate x₀2 = 2
- Calculate y₀-1 = -1
Engine last updated . Checked against 3 independently-derived tests — how we verify calculators. Built by Paul Gunder, a software engineer, not a licensed financial, medical, or legal professional.
Frequently Asked Questions
How does the calculator know a solution exists before solving for it?
It computes the greatest common divisor of a and b first and checks whether that divides c with no remainder. That single divisibility test, proven by number theory, is both necessary and sufficient — it is never wrong about whether an integer solution can be found.
What is the General Solution formula actually telling me?
It describes every integer solution at once using a free parameter t: starting from the one particular solution the calculator found, adding a multiple of b divided by the GCD to x and subtracting the matching multiple of a divided by the GCD from y always produces another valid pair.
What happens if a and b share a common factor that doesn't divide c?
The calculator reports directly that no integer solution exists, rather than offering a rounded or approximate pair. This is a case where the mathematics genuinely forbids any whole-number answer, so no amount of extra searching would ever turn one up.
How does the Extended Euclidean Algorithm find x-naught and y-naught, not just the GCD?
The ordinary Euclidean algorithm only tracks remainders while computing the GCD. The extended version also carries a pair of coefficients backward through each step, so by the time the GCD is found, those coefficients already express it as a combination of the original a and b.
Related Calculators
The questions that sit next to this one — chosen by subject, including calculators filed under a different category.
Chinese Remainder Theorem Calculator
Solve systems of congruences using the Chinese Remainder Theorem. Find x such that x ≡ r1 (mod m1) and x ≡ r2 (mod m2).
Number TheoryModular Arithmetic Calculator
Perform modular addition, multiplication, and exponentiation. Calculate (a op b) mod m with equivalence classes.
Number TheoryContinued Fraction Calculator
Convert a fraction to its continued fraction representation. Shows coefficients, convergents, and approximation error.
More in Math & Statistics.