Lecture 10
Coprimality
Now we’re going to introduce some very useful concepts. Rather than (as we were doing before) looking at one number at a time, it’s going to turn out to be really useful to consider two numbers and compare their factors.
Definition: Let and be integers. A common divisor of and is an integer such that and . The greatest common divisor of and , written (or sometimes as or sometimes even just for short) is the largest common divisor of and .
That definition probably just says that a greatest common divisor is what you’d expect it to be, given the name!
That definition is dangerous, because it does something I’ve warned you against doing several times: it defines something that looks like a function, but it doesn’t prove that it is a function.
There are two reasons why the gcd might not exist; we need to satisfy ourselves that neither is a problem:
There might be no common divisors at all (and hence no greatest common divisor): This is not a problem: we have observed before that is a divisor of every integer, and so will certainly be a common divisor.
There may be lots of common divisors, but no largest one. For nonzero integers , it’s easy to see that if then , which means we can’t get arbitrarily large divisors…but doesn’t exist.
As happens quite often, the remark above, which looks like a slightly pedantic point at first, really says something practically important. Indeed, it gives us a way of finding the greatest common divisor of two numbers: to find we could just count down from and stop when we reach the first common divisor.
For example, and
This approach to finding greatest common divisors is pretty terrible: imagine being asked to find by this approach!
Another way might be to work out all factors of one of the numbers (, for example) and work out which of them are factors of . That’s also a pretty terrible way, because factorising numbers is hard work: it seems like a lot of work to find all factors of still.
We will see a much better way soon, but, first, let’s spot some easy properties of greatest common divisors.
For all integers and , we have because the definition is symmetric in and .
Also, for all positive integers , we have and and
A slightly less obvious property is:
Proposition
Let and be integers. Then
Proof
We’ll show that the common divisors of and are the same as the common divisors of and .
Suppose first that is a common divisor of and ; in other words, and . Then we can write and for some integers and . But then so , so is a common divisor of and .
Similarly, if is a common divisor of and , then we can write and . But then so , so is a common divisor of and .
Since we’ve now proved that and have the same common divisors as and , it follows that they have the same greatest common divisor.
We should also mention that the greatest common divisor has a close cousin:
Definition: Given two positive integers and , the least common multiple is the smallest positive integer which is a multiple both of and .
Given that is a common multiple of and , the least common multiple always exists (and is at most : we could find it by counting up from to , stopping on the first common multiple).
The last piece of terminology we might want is this:
Definition: Two integers and are said to be coprime, or relatively prime, if .
Division with Remainder
The above Proposition looks slightly dry at first: so what if you can add multiples of one number to another number without changing their greatest common divisor?
It turns out this is the key step in a surprisingly efficient method for calculating greatest common divisors. We can use it to make the numbers smaller; the question is, how? It turns out that this is something familiar to you all:
Proposition
[Division with Remainder] Let and be integers, with . One can write for integers (the quotient) and (the remainder) such that .
It is not too hard to prove this: one can do it with two inductions, for example, (one for the negative and one for the positive integers), but I won’t do so here.
It’s reasonable to ask why we had to take . It’s true for , too, we just have to say that the remainder satisfies instead.
This observation gives us a really efficient way of computing greatest common divisors. Let’s illustrate it by an example.
Suppose we’re trying to compute . If we divide by we get with remainder ; in other words . That means that
That made the problem much smaller, and we can do the same trick repeatedly: That’s smaller still. Let’s see what happens next: As is a multiple of , of course we get remainder , so we stop here: the greatest common divisor is .
For another example, let’s suppose we want the greatest common divisor of and . We write