Shortly we will find it useful to be able to express gcd(a,b) as a linear combination of a and b; the following theorem lets us know this can be done:
Theorem: If a and b are positive integers then there exist integers n and m such that gcd(a,b) = na + mb.
We can easily (at least in principle) find the numbers n and m by "running the Euclidean algorithm backwards."
Start with the equation giving the GCD as the remainder and solve for the remainder; do not simplify any products that appear.
Solve for the remainder in the previous line and substitute that into the current equation. Simplify, keeping a linear combination of next two remainders. Repeat until the equation is a linear combination of a and b.