We turn the strategy from Example 4.2.7 into an algorithm for finding greatest common divisors. As in the example, we repeatedly apply Theorem 4.2.63. 4 to replace the computation of \(\gcd(a,b)\) with \(\gcd(a\fmod b, b)\text{.}\) At each step, the numbers become smaller. We stop when the remainder \(a\fmod b\) is zero.
The algorithm is named after the Greek mathematician Euclid. He first described it in Book 7 of his Elements (around 300 BC) [5]. To make the algorithm easier to present, we allow only natural numbers (positive integers) as inputs.
In the algorithm, \(r\) becomes smaller in each iteration of the loop. As \(r\) is a non-negative integer, it has to become zero eventually. So after finitely many steps the algorithm returns a result.
Next we repeat the previous example. Instead of explicitly writing down what happens in every step, we write down the value of each variable at the end of step 1. This notation is more suitable for the computation of greatest common divisors by hand.
Example4.3.4.Greatest common divisor of \(612\) and \(56\) compact.
We compute the greatest common divisor of \(612\) and \(56\) with Algorithm 4.3.2. In the table we give the values of the variables at the end of step 1 in each iteration of the loop.
Let \(n\) be a natural number. We compute \(\gcd(n+1,n)\) using the Euclidean Algorithm. with Algorithm 4.3.2. In the table we give the values of the variables after step (1) in each iteration of the loop.
We compute the greatest common divisor of \(238\) and \(237\) with Algorithm 4.3.2. In the table we give the values of the variables after step (1) in each iteration of the loop.