The Extended Euclid's Algorithm
Euclid's algorithm starts a sequence with and and proceeds by doing modular reductions on consecutive terms of the sequence until zero in reached.
Let the sequence begin with and . At any time, let . So, , and .
The next term of the sequence is given by . Let .
Then, , , and .
We have to stop wjem , at which time . But here we know more: .
If then , and this formula allows us to compute easily.
and
Example

Last updated