The extended Euclidean algorithm is an algorithm to compute integers xx and yy such that
given
The existence of such integers is guaranteed by Bézout’s Identity.
The extended Euclidean algorithm can be viewed as the reciprocal of modular exponentiation.
By reversing the steps in the Euclidean Algorithm, it is possible to find these integers
Let’s find
We start with our GCD. We rewrite it in terms of the previous two terms:
We replace for
Collect like terms, the
Repeat the process:
The final result is our answer:
Thus