Euclidean Algorithm
Euclidean Algorithm
This is a summary of the important definitions and results associated to the Euclidean algorithm,
along with examples of the algorithm in action.
Theorem 1 (Division algorithm). Let n and m be integers, with m > 0. Then there exist integers
q and r, with 0 ≤ r ≤ n − 1, such that
n = qm + r.
Definition 1. • We say that an integer m divides an integer n if there exists c ∈ Z such that
n = cm.
• The greatest common divisor of a and b, gcd(a, b), is the largest positive integer which
divides both a and b.
Euclidean algorithm: Given integers n and m (suppose that m < n), gcd(n, m) can be com-
puted as follows:
n = q0 m + r0 .
m = q1 r0 + r1 ,
3. Continue this process until you obtain a remainder of zero. The previous (nonzero) remain-
der is gcd(n, m).
gcd(n, m) = nx + my.
1
Example 2. Find gcd(105, 81).
105 = 1 · 81 + 24
81 = 3 · 24 + 9
24 = 2 · 9 + 6
9=1·6+3
6=2·3+0
gcd(105, 81) = 3.