For integers consider the linear form . It takes on all multiples of , all multiples of and all sums and differences of those numbers. Notice that when have a common factor (e.g. they are both even) then every value the linear form takes on will also be a multiple of that common factor.
It turns out that the smallest positive value this form takes on is the greatest common divisor of and . The best way to see this is along with the algorithm to compute it. In fact we'll present an algorithm to compute (the notation denotes the gcd of the two numbers) in
Starting with
then, supposing we can get represent a smaller number with this form by subtracting so that we now have:
continuing in this way you find the integers that produce the minimum positive value.
Here's an example of running this procedure for the form , to be more compact I'll write the equations as a table of numbers.
Upon reaching 0 the algorithm is complete, and the result is that and
There are two facts which are used to justify the correctness of algorithm.
Lemma 1: .
Lemma 2: implies .