Next: Modular Arithmetic
Up: Euclid's Algorithm
Previous: Example
Start with positive integers a<m.
In formulas, Euclid's algorithm looks like the following:
Subscripts are used to indicate the order in which the numbers appear.
For instance, q1, q2, ..., is the sequence of quotients.
The remainders form a sequence, too, with r-1=m, r0=a, r1,
r2, ..., rn+1=0. Because the remainder is always less than the
divisor,
these form a strictly decreasing sequence
The formula for the h's and k's are as follows:
This is called a two-term recurrence, because to get the next
term in the sequence, we have to use the previous two terms.
At every step in Euclid's algorithm we have
j is a subscript indicating which step we are at. The power (-1)jis -1 times itself j times; hence, it is +1 if j is even and
-1 if j is odd.
Therefore the very last nonzero remainder, which is the smallest,
satisfies
That last nonzero remainder rn is the greatest common divisor of aand m. If it turns out to be 1, then our equation says
after discarding the multiple of m.
That's why the solution to
is
x= (-1)n hn, or hn if n is even and -hn if n is odd.
Next: Modular Arithmetic
Up: Euclid's Algorithm
Previous: Example
David J. Wright
2000-09-11