Lecture 2: Prime Numbers

# Review & Summary

Yesterday we spent the class delving deeper into the depths of divisibility, seeing a few more basic examples and then working a couple of more complicated examples. We also spent a good bit of time talking about properties of divisibility, particularly when certain divisibility statements imply other divisibility statements. We concluded by talking about the division algorithm, a tool which we're using (for now) as a measure of failure of divisibility. The division algorithm says that for any positive integer d and any other integer a. there exist unique integers q and r with $0 \leq r < d$ that satisfy

(1)
$$a = qd + r.$$

Though we didn't talk about this much, the method for actually finding q and r is as follows

• q is selected as the largest possible integer so that $a-qd \geq 0$; in other words, you can find q by looking for the largest multiple of d which is less than or equal to a;
• with q selected, you can find r as $a - qd = r$.

In the ''real world,'' this means that to find q and r you often compute the fraction $\frac{a}{q}$ and then choose q to be the smallest integer below this number.

As for today, we're going to go on a whirlwind introduction to prime numbers. After giving the basic definitions, we'll work to show that they form the building blocks of the integers under multiplication. Then we'll talk at length about their properties and how one can go about looking for prime numbers.

# Prime Numbers

The star of number theory are the prime numbers. To recall yesterday's definition, we have

A number $p>1$ is said to be prime if the only positive divisors of p are 1 and itself. A number $n > 1$ is said to be composite if it is not prime; i.e., n is composite if there exist $1 < a,b < n$ so that $n = ab$.

The reason that prime numbers are so exciting is that, despite their foundational role in the multiplicative structure of the integers, they are very elusive. When I say that they are foundational in the multiplicative structure of the integers, I mean that any factorization of an integer n involves prime numbers as the atomic pieces — in the same way that any physical substance we encounter is built out of elements from the periodic table. And when I say elusive, I mean just that: the damn things are hard to pin down and understand. We'll talk more about both of these ideas — as well as some cool applications of primality — throughout the remainder of the course.

For now, though, we'll take a step in the first direction: showing that prime numbers are the building blocks of integers. For this, we begin with a nice lemma that says that any number is divisible by at least 1 prime number.

Lemma: For any integer $n>1$, there exists some prime number p which divides n.

Proof: We'll prove this result by contradiction: assuming the opposite of what we want to prove, manipulating this assumption until it reaches a contradiction, and then concluding that our assumption must be false — and hence our desired conclusion is true.

So suppose that not every integer n has a prime factor. This means that the set

(2)
\begin{align} S = \{1 < n \in \mathbb{Z}: p \nmid n \mbox{ for all primes }p\} \end{align}

is non-empty. As a non-empty set of positive integers, S must have a least element. We'll call this least element N.

Now N is an element of S, and hence has no prime divisor. Since N is a divisor of itself — $N \mid N$, after all — this means in particular that N cannot be prime. Therefore N is composite, meaning there exist integers $1 < a,b < N$ so that N = ab. Being positive integers less than N, both a and b must live outside of S, and hence each has a prime factor: say $p \mid a$ and $q \mid b$. But then $p \mid a$ and $a \mid N$, so that $p \mid N$, contrary to the defining property of N.

Having reached a contradiction, we conclude that S must, indeed, be empty, and so every integer greater than 1 has a prime factor. $\square$

This result is a baby version of a much larger theorem which we'll prove in a few sections — the so-called Fundamental Theorem of Arithmetic — but it already has a lot of nice consequences. For instance, it gives us a method for finding prime numbers using a sieve technique. Before we get there, we need to first make the following

Observation: If $n>1$ is a composite number, then there exists a prime divisor p of n such that $p \leq \root\of{n}$.

Proof: If n is composite, then there exist integers a and b so that n = ab. Now one of a or b must be less than $\root\of{n}$, since otherwise their product would be greater than n. Without loss of generality, we can assume that $a \leq \root\of{n}$. Now a has a prime factor p from the previous lemma, and so $p \leq a \leq \root\of{n}$. Since $p \mid a$ and $a \mid n$, we further have $p \mid n$, giving the desired result.

## A Sieve Example

The idea behind a sieve is to find prime numbers by eliminating multiples of known prime numbers. The magic, though, is that one has to use relatively few primes to sieve out larger ones.

Suppose, for instance, that you wanted to find all prime numbers less than 200. The previous observation says that any composite number $n \leq 200$ must have a prime factor which is smaller than $\root\of{n}\leq \root\of{200} \approx 14.14$. Hence any composite number smaller than 200 must be divisible by one of the primes which is smaller than 14 — namely one of 2, 3, 5, 7, 11 or 13. Hence if we listed all the numbers between 2 and 200 and crossed out the multiples of the primes listed above, the remaining numbers would all have to be prime.

Hence knowing the primes less than 14 gave us a method for finding the primes less than 200; more generally, knowing the list of primes less than n gives us a way to generate the list of primes less than $n^2$. While this is a great way to conclusively generate prime numbers, the downside is that this technique takes a LONG times to implement. Hence it is an effective but impractical method for finding really big prime numbers.

Having actually gone through and found a handful of small primes, we now begin to wonder what can be said about primes. Here are a few basic questions you might want to know

• how many primes are there? for instance, is the number of primes finite?
• if the number of primes isn't finite, do we at least have a reasonable guess as to how many primes there are of a given magnitude?
• do we know how "spread out" the prime numbers are? do they come in clusters, or should we expect that they are always far apart from each other?
• is there a formula which allows us to quickly generate prime numbers?
• do prime numbers obey any special properties? for instance, are there more primes which leave remainder 1 after division by 4 than there are primes which leave remainder 3 after division by 1?
• what can you say about how the primes behave under addition?

These are all good questions, and some of them have nice, easy answers. Alternatively, some of these questions are exceedingly difficult to investigate. We'll cover a sampling now.

## The Infinitude of Primes

The question on the number of primes has been around for a long time, and the answer was known at least two thousand years ago. Here's the proof that Euclid gave in his Elements.

Theorem: There are infinitely many primes.

Proof: Again, we'll proceed by contradiction: assuming there are finitely many primes, massaging this condition into a contradiction, and then concluding that a finite number of primes is impossible.

So suppose you have a list of all the prime numbers, and call them $p_1, p_2, \cdots, p_r$. Then we'll form the integer $N = p_1 p_2 \cdots p_r + 1$. Notice that for any $p_i$ in our list of primes, we cannot have $p_i \mid N$; if we did, then we'd also know that

(3)
\begin{align} p_i \mid N - p_1p_2 \cdots p_r = 1. \end{align}

But we know that N has to have at least 1 prime factor p. Since this prime number isn't one of the primes in our list, we conclude that the list of primes we started off with was incomplete. $\square$

## Gaps and Clusters in Primes

Now that we know there are infinitely many primes, we might want to have a reasonable idea of how the primes are spaced out amongst the integers. Displaying their typical quirkiness, the answer to this question seems to be on both extremes: some primes have wide gaps to their next neighbor, while — conjecturally, at least — others are as close as can be.

On the one extreme, we have a theorem which tells us that large gaps between primes numbers are known to exist.

For any positive integer M, there is a string of at least M consecutive composite integers.

Proof: The M integers between

(4)
\begin{align} (M+1)!+2, (M+1)! + 3, \cdots, (M+1)!+M+1 \end{align}

are all composite, since the first is divisble by 2, the second by 3, etc. $\square$

On the other hand, empirical evidence suggests that there are also lots of primes which are quite close to each other. The most famous result in this vein is

The Twin Prime Conjecture: There are infinitely many primes p such that p+2 is also prime.

You might want to put on your thinking cap and figure out why there aren't very many primes p such that p+1 is also a prime. For those who are interested, the record largest twin primes to date can be found at The Largest Known Primes Page; as of this morning, the largest twin primes were

(5)
\begin{align} 2003663613\cdot 2^{195000}\pm 1, \end{align}

two numbers which have something like 60,000 digits.

## The Prime Number Theorem

With all the spreading out and bunching up between the prime numbers, one might think that it would be hard to give an estimate for the number of primes of a given magnitude. However, one of the biggest results in number theory — and one which is almost always proved using techniques from complex analysis (!) — tells us exactly this information. It uses a function $\pi(x)$, which is defined as the number of primes less than or equal to a given number x. (So, for instance, we have $\pi(11) = 5$ since the primes less than or equal to 11 are $\{2,3,5,7,11\}$.

The Prime Number Theorem: $\frac{\pi(x)\ln(x)}{x} \to 1$ as $x \to \infty$.

# Primes of a particular form

Now that we know a little bit about primes, it is natural to ask: how can we go about finding them? The answer to this question, sadly, is that there's not really a general method for finding all primes aside from ''brute force'' techniques like our sieve method. Indeed, the difficulty in finding primes is one of the hard problems which helps keep our world afloat right now: encryption online is dependent on the fact that it's really hard to factor large numbers.

Even though it's hard to come up with an exhaustive list of all primes, there are some places where prime hunters go to search for big game. Although finding large primes was a kind of pleasant amusement amongst mathematicians a hundred years or so ago, today it is big business: the aforementioned internet security applications of primality require large primes to work. Hopefully we'll be able to talk about all this more at the end of the term.

## Mersenne Primes

The largest primes found these days all happen to take a particular form: they can be expressed as $2^p-1$ for a prime number p. These are the so-called Mersenne Primes. There was a recent development (i.e., this weekend), when the Great Internet Mersenne Prime Search (GIMPS) came across what they believe to be the new largest prime number. This number has around 10 million digits, and it will take a couple of weeks to verify that it is, indeed, a prime number. If you want, you can use your computer to help GIMPS out; maybe it will be your computer which finds the next largest prime!

The reason that the largest primes found these days happen to be Mersenne Primes is that they are the easiest numbers to check for primality on a binary computer. This is an important take-home lesson: even though it's hard to check whether a randomly chosen large number is prime, large numbers which satisfy some particular condition might be easier to check for primality.

## A Generalization of Mersenne Primes (?)

Now that we're moving into some truly substantial mathematics, you should start trying to think of entries you could make to the idea journal. Having talked about Mersenne primes, perhaps you might wonder about the following

Question: Are there infinitely many Mersenne primes?

This, indeed, is a great question, and is a problem in number theory which many mathematicians would love to know the answer to! If you had thought about this (and if I hadn't spoiled the question by talking about it in class), this would have been a great question for the Idea Journal.

On the other hand, you might have wondered

Question: Are there any primes of the form $n^p-1$ when $n \neq 2$?

or perhaps

Question: Are there any primes of the form $2^n-1$ when n isn't a prime number?

Both of these questions involve minor changes to the concept of a Mersenne prime, and so they are really reasonable questions to ask. As it happens, both of these questions already have an answer, but that isn't the thing that's most important for the journal; the important thing is that you try to engage with the material with creatively, asking new questions which your book doesn't cover.

## Generating Primes Through Polynomials

We asked earlier if there was any formula we could use to generate prime numbers, something which would make discovering new prime numbers as simple as plug-and-chug.

A long time ago the amazing mathematician Leonard Euler showed that the polynomial

(6)
$$n^2+n+41$$

generates distinct prime values for all integral inputs between 0 and 39. This was an amazing discovery, and even today the record for producing consecutive primes by a polynomial sits at just 57 (in 2005, the record was just 43!). So one might ask: is there a polynomial out there which only takes prime values? Sadly, the answer is know. However..

## Almost Prime-Generating Polynomials

A prime generating polynomial is supposed to only have prime values as it's outputs, and we have just seen that no such polynomial exists. But what if we tried to find a polynomial whose positive values where all prime? Amazingly, these polynomials do exist! The ''smallest'' such polynomials have

• degree 5 and 42 variables
• 10 variables and degree $10^{45}$ (!)

Although they are explicitly written down, they aren't good for producing prime numbers because they are so rarely positive.

## Other Prime Generating Functions

There are a handful of other methods for producing primes; while all sound nifty, none of these (sadly) are practical for actually finding prime numbers. Here's a sampling. Can you find more?

• There exists a real number x such that $\lfloor x^{3^n} \rfloor$ is always prime (where here the function $\lfloor z \rfloor$ means the largest integer n such that $n \leq z$).
• The sequence $a(n) = a(n-1) + gcd(n,a(n-1))$ with starting value $a(1) = 7$ generates only prime numbers and the number 1 when you computer successive differences $a_n-a_{n-1}$.