Extended Eucledian Algorithm
The Extended Euclidean Algorithm is an essential algorithm in number theory. For given integers $a$ and $b$, the extended Euclidean algorithm not only calculate the greatest common divisor $d$ but also two additional integers $x$ and $y$ that satisfy the following equation. $$ax + by =d= gcd(a, b)$$ The existence of such integers is guaranteed by Bézout’s lemma. Here’s how it works: Problem Statement: Given integers $a$ and $b$, find integers $x$ and $y$ such that $ax + by = gcd(a, b)$. Algorithm Steps: Start with the GCD of $a$ and $b$. Reverse the steps in the Euclidean algorithm to find $x$ and $y$. Treat the numbers as variables and work our way backward to express the GCD as a linear combination of $a$ and $b$ Example: Given $a = 11$ and $b = 3$. We start with the GCD: $$11=3.3 + 2$$ $$3=1.2+1$$ $$2=2.1+0$$ So GCD=gcd(11,3)=1 Now we can reverse the process. Repeatedly replace terms until we get the final result.We have to consider the coefficient of $a$ and $b$ as variable