Linear Diophantine Equation Solver
Use this calculator to solve equations of the form ax + by = c in integers.
Sample integer solutions range (parameter t)
What this diophantine equations calculator does
A Diophantine equation asks for integer solutions rather than decimal or real-number answers.
This tool focuses on the most common case: the linear equation in two variables,
ax + by = c.
Instead of giving just one answer, the calculator tells you whether:
- no integer solution exists,
- exactly constrained forms exist (through a parameter), or
- every integer pair works (in the special
0x + 0y = 0case).
t.
How to use the calculator
Step 1: Enter coefficients
Type integer values for a, b, and c. These can be positive, negative, or zero.
Step 2: Set a sample parameter range
If solutions exist, the calculator expresses them using parameter t. Set a range (for example, -3 to 3) to view concrete sample pairs.
Step 3: Click “Solve Equation”
You’ll get:
- the gcd condition check,
- a particular integer solution,
- the general solution formula,
- and a table of sample integer solutions.
The math behind the result
The gcd test
Let g = gcd(a, b). The equation ax + by = c has an integer solution if and only if g divides c.
This is the most important test in linear number theory for two variables.
Extended Euclidean Algorithm
When g | c, we use the Extended Euclidean Algorithm to find integers u and v such that:
au + bv = g.
Multiplying by c/g gives one particular solution (x₀, y₀).
General integer solution
Once one solution is known, all integer solutions are:
x = x₀ + (b/g)t
y = y₀ - (a/g)t
where t ∈ Z.
Example walkthrough
Try 15x + 21y = 84.
Here, gcd(15, 21) = 3, and 3 divides 84, so solutions exist.
The calculator finds one valid pair and then generates all others with the parameter formula.
If you change it to 15x + 21y = 85, then 3 does not divide 85, so no integer solution exists.
Common use cases
- Checking solvability constraints in number theory homework.
- Building integer combinations in coding and algorithm challenges.
- Working with modular arithmetic and congruence transformations.
- Testing integer feasibility before optimization steps.
Limitations
This calculator solves linear two-variable Diophantine equations only.
It does not directly solve nonlinear forms like x² + y² = n or systems with many variables.
For those cases, additional theory or computational search methods are required.
Quick FAQ
Why do I get infinitely many answers?
Because once one integer solution exists for ax + by = c, moving by the step vector
(b/g, -a/g) preserves equality, producing new integer solutions forever.
What if one coefficient is zero?
The calculator handles it automatically. For example, if a = 0, the equation becomes by = c, so solvability depends on whether b divides c.
Can I use large integers?
Yes. This page uses integer-safe BigInt arithmetic for core calculations.