# Lecture 9

The following definition is a natural one:

**Definition:** An integer $p>1$ is said to be *prime* if it has no positive factors except for $1$ and $p$ itself.

Primes are clearly a good thing to study: they’re the numbers with no complicated factors.

It’s good to have a word meaning roughly the same thing as “not prime”:

**Definition:** An integer $n>1$ is said to be *composite* if it is not prime: that is, if it does have positive factors other than $1$ and $n$.

Notice that we have chosen our definitions so that $1$ will be neither prime nor composite. This was a choice, and it seems a bit mysterious at first.

Indeed, until the late 19th century, mathematicians treated $1$ as prime. But it was found to be so much simpler to do it this way that nobody considers $1$ to be prime any more.

The main thing about primes is that all other positive integers are built from them by multiplication.

Before we get to that, it’s worth explaining something about multiplication.

You’re all used to the fact that the sum of an empty list of numbers is zero. I want to persuade you that the product of an empty list of numbers is one.

Suppose I’m trying to find $2\times 3\times 4\times 5$.

One way of doing this would be to ask one person to find $2\times 3$ and another to find $4\times 5$, and then multiply the results: $(2\times 3)\times(4\times 5) = 6\times 20 = 120.$ I could split the work up in other ways: $\begin{aligned} {(2\times 4)\times(3\times 5)} &{= 8\times 15 = 120}\\ {(2\times 3\times 4)\times(5)} &{= 24\times 5 = 120}\end{aligned}$ What if I give all the numbers to the first person? $(2\times 3\times 4\times 5) \times (?) = 120\times ? = 120$ For the right answer, the product of no numbers must be 1.

#### Proof

We’ll prove this by strong induction on $n$.

For our base case, we observe that when $n=1$, we can write $n$ as the product of no primes.

So now we have to do our induction step: let $k$ be a positive integer. We assume that every positive integer $i$ with $1\leq i<k$ can be written as a product of primes, and we try to prove that $k$ can.

Now, either $k$ is prime, or it is composite. If it is prime, then $k$ is the product of just one prime (namely, $k$ itself).

If, however, $k$ is composite, then it has a positive integer factor $a$ which is not $1$ nor $k$ itself: in other words, we have $k = ab$, where both $a$ and $b$ are between $1$ and $k$. By the induction hypothesis, $a$ and $b$ can both be written as products of primes, say: $a = p_1p_2\cdots p_m,\quad\text{and}\quad b = q_1q_2\cdots q_n.$ But then $k = ab = p_1p_2\cdots p_mq_1q_2\cdots q_n$, which proves it for $k$. That completes the induction step (and the proof).

Later on, we’ll prove a stronger result, that every number can be written as a product of primes in *exactly* one way (rearranging the factors doesn’t count). That’s much, much harder.

Because of this we can be sure that primes are reasonably important. The first few are:

$2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47$

What are sensible questions to ask? Here are some obvious examples:

How many primes are there?

There’s quite a lot of primes between $1$ and $50$. Do they tend to get rarer as we go on?

Other than $2$ and $5$, all primes must end in $1$, $3$, $7$ or $9$. Is there a bias: do more end in $3$ than in $9$, for example?

There seem to be several pairs of small primes which differ by $2$ (eg $3$ and $5$, and $5$ and $7$, and $11$ and $13$). How many such pairs are there?

Are there quick ways of testing if a number is prime?

Are there quick ways of finding large primes?

Some of these have had well-known answers for more than a century, some are still unsolved, and some are currently the focus of tremendous interest.

We’ll start off by giving the answer to that first question, which was known to the ancient Greeks:

Here’s the proof, the way I prefer to think of it:

#### Proof

We’ll construct a sequence $p_1,p_2,p_3\ldots$ of different primes by induction (so, the statement we’re doing induction on is, “there are at least $n$ different primes”).

For our base case we take $n=1$, and then take $p_1=2$, which is a prime.

For our induction step we suppose we have primes $p_1, \ldots, p_n$, and our job is to show that there’s another prime.

Consider the natural number $p_1p_2\cdots p_n + 1$ obtained by multiplying all our primes so far and adding $1$.

This number is not a multiple of $p_1$, because $p_1\cdots p_n$ is: so $p_1\cdots p_n+1$ leaves a remainder of $1$ when you divide by $p_1$.

Similarly, it’s not a multiple of $p_i$ for any $i=1,\ldots,n$, because $p_1\cdots p_n$ is, and so $p_1\cdots p_n+1$ leaves a remainder of $1$ upon division by $p_i$.

But this number has at least one prime factor: we can take our next prime $p_{n+1}$ to be one such prime factor, and that completes the induction step.

Here’s pretty much exactly the same proof, phrased in a slightly different way.

#### Proof

[Proof (of the same theorem again)] We prove this by *contradiction*: we show that it’s true by showing that the negation is absurd.

Indeed, suppose there were only finitely many primes, $p_1,\ldots,p_n$. Then consider (as before) the natural number $p_1\cdots p_n+1.$ This isn’t divisible by any of the primes $p_1,\ldots,p_n$ (since it leaves a remainder of $1$ upon division by any of them). But that’s absurd, since we were assuming those were all the primes, and that every number can be written as a product of primes.

Some people find proof by contradiction slightly startling when they see it first.

In fact, it’s perfectly familiar in daily life. When you find someone who disagrees with you, you show that you are right by pointing out that if you were wrong, then that would contradict something well-known to be correct.

From a logical perspective, it’s all to do with the . Suppose $P$ is some result we desperately want to prove, for example $P = \text{``there are infinitely many primes''},$ and $T$ something we know is true, for example $T = \text{``every positive integer has a prime factor''}.$ (That was Theorem ).

Now, we proved that if there are only finitely many primes, then some number doesn’t have a prime factor. That’s exactly $\neg P\Rightarrow\neg T$. But that means that its contrapositive $T\Rightarrow P$ is true. And once we know that, then, since we know $T$ is true, we also know $P$ is true.

The second form above, the proof by contradiction, is a more standard form. It appears in the majority of textbooks (and maybe the majority of mathematicians’ minds).

This makes me sad, because it’s not as good. The proof by contradiction spends all its time making fun of the idea that there might not be infinitely many primes; the first one just goes and builds them.

There are (quite a lot of) other proofs of Euclid’s theorem, but Euclid himself probably only knew the way we’ve discussed.

That means that you can actually use the first proof to construct primes:

We start with $p_1 = 2$.

We find that $p_1+1 = 3$ is prime, so we take $p_2 = 3$.

In fact, $p_1p_2+1 = 7$ is also prime, so we take $p_3 = 7$.

Further, $p_1p_2p_3 + 1 = 43$ is also prime, so we take $p_4 = 43$.

Now, $p_1p_2p_3p_4 + 1 = 1807$. It turns out that’s not prime: in fact, $1807 = 13\times 139$. So we could take $p_5$ to be either $13$ or $139$…

This is genuinely a way of producing primes. Admittedly, it’s not a very intelligent one.

If you have to find primes, it’s probably better to use this method, which works well in practice:

#### Algorithm

[The Sieve of Eratosthenes] The *Sieve of Eratosthenes* proceeds by writing down the natural numbers from $2$ up to $N$ (for some $N$) in a convenient form. We repeat the following steps:

Find the first untouched number and mark it as a prime.

Mark all its multiples as being composite.

The Sieve of Eratosthenes doesn’t prove that there are infinitely many primes: it just finds them. Unless we’d found a proof of Euclid’s theorem, we could have nightmares that one day we’ll find ourself crossing off all the remaining natural numbers and not finding any more primes.