Lecture 4: The Euclidean Algorithm and the Fundamental Theorem of Arithmetic

Recap & Summary

Last class period we talked about greatest common divisors and least common multiples. We saw some of the basic properties of both, and we also saw that they are intimately connected to one another.

Today we'll begin by giving a computationally efficient way for computing GCDs known as the Euclidean Algorithm. In practice, this is how GCDs of large numbers are actually computed. Afterwards we'll discuss and prove the Fundamental Theorem of Arithmetic.

The Euclidean Algorithm

Greatest Common Divisors might seem like a boring subject to you, since likely you already saw GCDs when you were in high school. The kinds of GCDs you were after then — between pairs of numbers which are relatively small and easily factored — are quite different from the kinds of GCDs people care about in practice — namely between pairs of numbers which are much too large to easily factor. For this reason, we need a method for computing GCDs effeciently. The idea for this method comes from the remarkably simple

Lemma: Suppose that a and b are integers and that $a = qb + r$ as per the Division Algorithm. Then $(a,b) = (b,r)$.

Proof: This is really not a hard proof. Suppose that d is a common divisor of a and b. Then since $r = a-qb$, we have that d is a divisor of r as well (using our "divisibility of integral linear combinations" result).

Likewise, if d is a common divisor of b and r, then since $a = qb + r$ we have that d is also a divisor of a.

Hence all common divisors of a and b are also common divisors of b and r, and vice versa, proving that the greatest elements amongst these common divisors are the same. $\square$

We can apply this idea iteratively to give a computationally effective way to computer GCDs. This process has been known for a long time and — like many other ideas from this chapter — was outlined in Euclid's Elements. For that reason, it bears the moniker of the Euclidean Algorithm.

Example: Computing GCDs with the Euclidean Algorithm

Suppose you're interested in computing (8633,6319). Using the previous result, since

\begin{equation} 8633 = 6319 + 2314 \end{equation}

we know that this GCD is the same as (6319,2314). In fact, we can keep using this result over and over again, provided we keep using the division algorithm every time we get a non-zero remainder. These applications of the division algorithm are:

\begin{align} \begin{split} 6319 &= 2\cdot 2314 + 1691\\ 2314 &= 1\cdot 1691 + 623\\ 1691 &= 2\cdot 623 + 445\\ 623 & = 1\cdot 445 + 178\\ 445 &= 2\cdot 178 + 89\\ 178 &= 2\cdot 89 + 0. \end{split} \end{align}

Hence we have

\begin{align} \begin{split} (8633,6319) &= (6319,2314) = (2314, 1691) = (1691,623) \\&= (623,445) = (445,178) = (178,89) = (89,0) = 89. \end{split} \end{align}

Example: Expressing GCD as a linear combo

This same procedure can be used to write the GCD between a and b as an integral linear combination of the two. In the previous computation, for instance, the second-to-last division algorithm application gives

\begin{align} 89 = 445 - 2\cdot 178 \end{align}

The previous application of the division algorithm, though, showed us that $178 = 623-445$, and hence we can substitute this into our expression for 89:

\begin{align} 89 = 445 - 2\cdot 178 = 445 - 2(623-445) = 3\cdot 445 - 2\cdot 623 \end{align}

Using the equality $445 = 1691 - 2\cdot 623$ and substituting again gives

\begin{align} 89 = 3\cdot 445 - 2\cdot 623 = 3(1691 - 2\cdot 623) - 2\cdot 623 = 3\cdot 1691 - 8\cdot 623 \end{align}

Continuing this kind of back substitution gives

\begin{align} \begin{split} 89 &= 3\cdot 1691 - 8\cdot 623\\ &=3\cdot 1691 - 8(2314 - 1691) = -8 \cdot 2314 + 11 \cdot 1691\\ &= -8\cdot 2314 + 11(6319 - 2\cdot 2314) = 11\cdot 6319 - 30\cdot 2314\\ &= 11\cdot 6319 - 30(8633 - 6319) = -30 \cdot 8633 + 41 \cdot 6319 \end{split} \end{align}

The Fundamental Theorem of Arithmetic

Having covered many of the basics, it's now time for us to knock down the Fundamental Theorem of Arithmetic. This theorem is something which you all have seen many times before — whether explicitly or not — and is an incredibly useful tool in number theory. Recall its statement:

The Fundamental Theorem of Arithmetic: Any integer $n>1$ can be uniquely expressed as a product of prime numbers.

We won't prove the result quite yet, since we need a preliminary result before we can knock down the Fundamental Theorem. This preliminary result is known as Euclid's Lemma, and it is essentially a special case of one of you homework problems for the week (44a).

Euclid's Lemma: If p is a prime number and $p \mid ab$, then either $p \mid a$ or $p \mid b$.

Proof: Suppose that $p \nmid a$, and we'll argue that $p \mid b$. For this, notice that $p \nmid a$ forces $(p,a) = 1$ — the only divisors of p are 1 and itself, and we already know that p isn't a divisor of a. Applying 44a gives the desired result. $\square$

We can every take this result a little further, arguing that a prime which divides any product of integers (no matter how many) must divide one of the factors.

Corollary: If p is a prime number and $p \mid a_1\cdots a_r$, then $p \mid a_i$ for some $i \in \{1, \cdots, r\]$.

Proof: We'll apply induction to the previous result. Our base case — when $r = 2$ — is already handled by Euclid's Lemma. So suppose we know that if p divides any product of r-1 integers, then p divides one of those integers. We'll show that if $p \mid a_1\cdots a_r$, then $p \mid a_i$ for some $i \in \{1, \cdots, r\}$.

Notice that if $p \mid a_1\cdots a_r$ then $p \mid a_1 \left(a_2 \cdots a_r\right)$. Applying Euclid's Lemma (with $a = a_1$ and $b = a_2\cdots a_r$) then shows $p \mid a_1$ of $p \mid a_2\cdots a_r$. In the former case we're done, and in the latter case we can just apply the induction hypothesis to conclude $p \mid a_i$ for some $i \in \{2, \cdots, r\}$. Together this gives the desired result. $\square$

The Proof of the Fundamental Theorem

We're now ready to prove the Fundamental Theorem of Arithmetic. We'll break our proof into two parts

  1. Existence: that every $n > 1$ can be written as $n = p_1\cdots p_r$ for some prime numbers $p_i$
  2. Uniqueness: there is only one such way to factor a given integer

Existence: Suppose that there were integers greater than 1 which couldn't be factored into a product of primes. This would mean that there is a smallest such integer (by the well-ordering principle), and we'll call this smallest element n. Now n can't be prime since otherwise n is already an expression of itself as a product of primes. Hence $n = ab$ for some $1 < a,b < n$. Since both a and b are smaller than n, this means that they must be elements which do have prime factorizations (since n was selected as the smallest positive integer which didn't have this property). Therefore $a = p_1 \cdots p_k$ and $b = q_1 \cdots q_r$ for appropriate primes $p_i,q_j$. But then we have

\begin{align} n = ab = p_1\cdots p_k q_1 \cdots q_r, \end{align}

a prime factorization of n. Since this contradicts the selection of n as the least element without a prime factorization, we must conclude that every integer greater than 1 can be factored as a product of primes.

Uniqueness: To show that any integer n has only one prime factorization, suppose we're given two factorizations of an integer n:

\begin{align} n = p_1^{a_1}\cdots p_r^{a_r} = q_1^{b_1} \cdots q_s^{b_s}. \end{align}

This expression just means that each of the $p_i, q_j$ are prime, and that the corresponding exponents are positive.
We aim to show that the list of primes $\{p_1, \cdots, p_r\}$ and $\{q_1,\cdots, q_s\}$ are indeed the same, and moreover that the corresponding exponents match up as well.

For this, we start by noting that for each $i \in \{1, \cdots, r\}$, the term $p_i$ clearly divides the first expression of n as a product of primes. For this reason we must also have $p_i \mid q_1^{b_1}\cdots q_s^{b_s}$, and the supped up version of Euclid's Lemma says that $p_i \mid q_j$ for some j. But since $q_j$ is prime, this means that in fact $p_i = q_j$. Hence the list of primes for the first factorization is a subset of the list of primes for the second factorization. Running the same argument for a given prime $q_j$ in the second factorization, we have that the list of primes for the second factorization is a subset of the list of primes for the first. Hence the list of primes are, in fact, identical. And not just identical as sets, but — by virtue of our increasing ordering of the $p_i$ and $q_j$ — we must in fact have $p_i = q_i$ and $r = s$.

Now that the lists of primes are identical, we just need to show that $a_i = b_i$. For this, suppose that $a_i > b_i$. Then we have

\begin{align} \frac{n}{p^{b_i}} = p_1^{a_1}\cdots p_{i-1}^{a_{i-1}} p_i^{a_i-b_i} p_{i+1}^{a_{i+1}}\cdots p_r^{a_r} = p_1^{b_1}\cdots p_{i-1}^{b_{i-1}} p_i^{b_i-b_i} p_{i+1}^{b_{i+1}}\cdots p_r^{b_r}. \end{align}

Now clearly $p_i$ divides the first expression (since $a_i - b_i > 0$), whereas it cannot divide the second expression (since $p_i$ doesn't show up in the factorization). This is a contradiction, and so we must have $a_i \leq b_i$. A similar argument shows that $a_i < b_i$ is impossible, and so we have $a_i = b_i$. $\square$

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License