StatGardenREF. DESK
Calculators/Maths/Linear Diophantine equation (ax + by = c)
Maths

Linear Diophantine equation (ax + by = c) calculator

Finds all integer solutions to ax + by = c using the extended Euclidean algorithm.

What this calculator does

Linear Diophantine equation (ax + by = c) works out finds all integer solutions to ax + by = c using the extended Euclidean algorithm. Enter your own figures above and the answer updates as you type: nothing is fixed in the code, so the result reflects exactly the numbers you supply.

The formula this calculator evaluates is printed under the tool and explained below, so you can check the working by hand or reuse it in a spreadsheet.

The formula

FormulaSolvable iff gcd(a,b) divides c; general solution x=x₀+(b/g)t, y=y₀−(a/g)t for any integer t

The inputs explained

FieldWhat to enter
aA number. Starts at 12.
bA number. Starts at 18.
cA number. Starts at 30.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

How the answer changes with a

Every other input is held at the calculator’s starting values while a varies. Select any row to load that scenario into the calculator.

How the answer changes with a
aParticular solution (x₀, y₀)General solutiongcd(a, b)
65, 0x = 5 + 3t, y = 0 − 1t6
9gcd(a,b) = 9 does not divide c = 309N/A
12-5, 5x = -5 + 3t, y = 5 − 2t6
18gcd(a,b) = 18 does not divide c = 3018N/A
245, -5x = 5 + 3t, y = -5 − 4t6
36gcd(a,b) = 18 does not divide c = 3018N/A