Q:

How would one solve a linear equation in two integer variables?

For example, how would I find integers $a$ and $b$ that satisfy the following equation?
$$5a - 12b = 13$$
I always resorted to trial and error when doing something like this and more often than not I would finally reach my answer. But for this one I just kept going and going to no avail. So it finally brought about the concern that trial and error wasn't always going to work.
So what would be the best way to get two integer solutions to the above equation?

A:

Use the Euclidean Algorithm to find the gdc of $5$ and $12$.
$$12=5\times2+2$$
$$5=2\times2+1$$
Then apply the extended Euclidean Algorithm, (do the initial algorithm in reverse with back-substitution)
$$1=5-2\times2$$
$$1=5-2\times(12-5\times2)$$
$$1=5\times5-2\times12$$
Then multiply throughout by $13$
$$13=65\times5-26\times12$$
This gives you a particular solution $(a,b)=(65,26)$. The general form of any solution of a Linear Diophantine equation is given as follows
$$a=a_0-\frac{12}{d}t,\ b=b_0-\frac{5}{d}t$$
Where $t$ is any integer and $d$ is the greatest common divisor of $5$ and $12$ which is $1$

A:

The Euclidean algorithm is best for large numbers, but for a small example like this, trial and error, combined with a little modular arithmetic works just fine, and is less work.  Reducing $5a−12b=13$ modulo $12$, we have $a\equiv 1 \pmod{12},$ and $a\equiv 5 \pmod{12},$ by trial.  Then it's clear that $a=5,$ $b=1$ is a solution.
Alternatively, we might reduce modulo $5,$  getting $3b \equiv 3 \pmod{5},$ so $b\equiv 1 \pmod{5},$ and again we find that $b=1$ gives $a=5.$    

A:

Guide:
Since we know that $5$ and $12$ are coprime, use Eucliean Algorithm to find $x, y \in \mathbb{Z}$ such that $$5x+12y = 1$$
After which, multiply the equation by $13$.
In general to solve for $$Aa-Bb=C$$ where $A,B, C$ is given.
Use euclidean algorithm to find $\gcd(A,B)=D$, if $D$ doesn't divide $C$, then there is no integer solutions. Otherwise, express $D$ as a linear combination of $A$ and $B$ and multiply the equation to get a particular solution. 

