The greatest common divisor of two integers can be found by listing divisors, but this method becomes inefficient for large numbers. For example, finding
The Problem of Computing GCDs
The greatest common divisor of two integers can be found by listing divisors, but this method becomes inefficient for large numbers. For example, finding
by listing all divisors would be tedious.
The Euclidean algorithm gives a fast and systematic method. It reduces a gcd problem to smaller gcd problems by repeated division with remainder.
Basic Principle
The key identity is
where
and
This works because the common divisors of and are exactly the common divisors of and .
Indeed, since
any integer dividing both and also divides . Conversely, since
any integer dividing both and also divides .
Thus the gcd is unchanged when is replaced by .
The Algorithm
Let and be positive integers with .
Apply the division algorithm:
If , then
If , divide by :
Continue:
and so on.
The remainders strictly decrease:
Since there is no infinite strictly decreasing sequence of nonnegative integers, the process must stop. The last nonzero remainder is the greatest common divisor.
Example
Compute
First divide by :
Then divide by :
Then divide by :
The last nonzero remainder is . Therefore
Why the Algorithm Terminates
At each nonzero step, the new remainder is smaller than the previous divisor. Thus the sequence of positive remainders is strictly decreasing.
A strictly decreasing sequence of positive integers cannot continue forever. Eventually a zero remainder must occur.
This termination argument depends on the well-ordering principle for the natural numbers.
GCD Preservation
The essential step is the equality
Since the remainder is
this gives
This identity is often more important than the algorithm itself. It shows that one may replace a number by its remainder modulo another number without changing the gcd.
For example,
Negative Integers
The Euclidean algorithm is usually stated for positive integers, but it applies to arbitrary integers by taking absolute values:
Thus, for example,
If one of the integers is zero, then
for .
Efficiency
The Euclidean algorithm is efficient because each step reduces the size of the numbers. In many cases the numbers shrink very quickly.
For example, instead of testing all divisors of and , the algorithm uses only three divisions.
The worst case occurs when the remainders decrease as slowly as possible. This is closely related to consecutive Fibonacci numbers. Even then, the number of steps grows only logarithmically with the size of the input.
This efficiency is one reason the Euclidean algorithm is one of the oldest and most important algorithms in mathematics.
Role in Number Theory
The Euclidean algorithm is central to elementary number theory. It computes greatest common divisors, proves Bézout identities, solves linear Diophantine equations, finds modular inverses, and supports the Chinese remainder theorem.
Its importance comes from a simple idea: division with remainder reduces arithmetic questions to smaller ones without changing the essential divisibility structure.
The algorithm is therefore both computational and theoretical. It gives a method for calculation and a framework for proof.