Definition.

Let and be naturals that are not both zero. The greatest common divisor of and , denoted is the largest integer that divides both and . Similarly, the least common multiple, denoted is the smallest integer that is divided by every element both. Both of these concepts are generalized to more than two elements, although we will rarely use them.

Two integers and are called coprime or relatively prime if . I denote this phenomenon by .

Reflect.

What does the word largest in the definition above mean precisely? Am I referring to the usual order of integers , or the divisibility order instead? What is the relationship between these two anyway?

Exercises.

  1. If a prime does not divide , then .
  2. Prove that consecutive integers are coprime.
  3. If is prime and , then . If, moreover is also prime, then necessarily .
  4. Different primes are always coprime. Show with an example that the converse does not hold. That is, show that coprime numbers need not be prime.

Exercise.

Let be integers and their GCD. Then, and are relative primes.

The Euclidean algorithm

I now introduce one of many examples in mathematics where the statement of the theorem is not that important, but the proof is crucial to understand the material.

Theorem (Euclidean algorithm).

Assume that, for naturals and , the Q-R formula gives . Then,

Reflect.

Again, spend some time thinking why is this called an algorithm; there aren’t any steps!

Exercise.

Use the theorem to implement this as an actual computer program that computes the .

I will answer the important question of how to use this in the following subsection. More importantly, I will skip the proof for now, since understanding a particular case should make the proof idea apparent.

The extended Euclidean algorithm

Note:

These sort of examples with many moving steps are best understood during a live lecture, not reading them on a static site.

Let me do an example where I compute using the Euclidean algorithm.

First I divide and find the remainder: . Thus, .

Now I repeat these steps until I reach something trivial. Note: if you do not know why this must happen eventually, you have not understood the theorem and should go back to the previous section.

The last remainder before reaching zero is always the ; in this case .

Reflect.

What would happen if I wanted to compute instead? Obviously it should give me the same answer, but the algorithm does something different, since it always divides the left by the right. How does this work?

Notice that I can do the steps in reverse and obtain the remainder as a linear combination of the two previous rows. Repeatedly doing this backwards, I can write the final remainder in terms of the first two terms, and . The math paragraph below should be read from bottom to top, so it aligns with the math paragraph above.

Therefore, . The fact that the is a linear combination of the numbers can be proved more directly too. This is the purpose of the next section.

Bézout’s identity

Here is an important result that can be proved using Induction.

Theorem (Bézout's identity)

The least linear combination of two integers, not both zero, and is precisely .

In particular, and are coprime if and only if there exist integers such that .

Exercise.

Prove that the product of two relative primes that divide , divides .

The following consequences follow rather easily, but are non trivial if proved from just the definitions.

Exercise (Euclid's lemma 1).

If is prime and , then either or .

The same idea can be used to prove the slightly more general result:

(Euclid's lemma 2)

Suppose that and , then .

Exercise.

Prove that for every integer at least 5 of the form , is divisible by 24.

Hard exercise.

Prove this generalization of Bézout’s identity. Let be a positive natural and take a set of integers . Then,