Click the button to generate a two-variable simultaneous equation with integer solutions.

$$\begin{align} ax + by &= e \\ cx + dy &= f \end{align}$$

Click the button to reveal the answer.

$$\begin{align} x &= m \\ y &= n \end{align} $$
HOW IT WORKS

The code makes use of Bezout's Identity and the Extended Euclidean Algorithm to calculate the modular multiplicative inverse of a modulo b and b modulo a and then generates values of c and d to guarantee the matrix of coefficients has a determinant equal to 1. It then makes use of Cramer's Rule to find the solution. The determinant being equal to 1 guarantees the solutions are always integers.