There is an alternative definition where we allow negative integers so \(-2, -3, -5, ...\) are primes. In this case, we define an integer to be a prime as follows
Primality Testing
Suppose we want to know if \(101\) is prime. Naively, we can check all the numbers \(2, 3, ..., 100\) that they don’t divide \(101\). But that’s wasteful. In fact,
- We only need to check primes since if \(6 \mid n\), then we know \(2 \mid n\) and \(3 \mid n\)
- We only need to check primes up to \(\sqrt{n}\). This is because if \(n = ab\) and \(a,b \geq \sqrt{n}\), then \(ab \geq n\) but that's a contradiction.
So the number of steps in this algorithms is about \(\sqrt{n}\). If \(n\) is large, then this algorithm becomes really slow.
Fundamental Theorem of Arithmetic
Note: \(1\) is defined to be the product of the empty set of primes. This version of the theorem is for positive integers. If we want to consider negative integers, then
Proof (first version, existence)
The easy part of the proof is proving existence. The harder part is proving uniqueness. To show existence, then we can use induction. For the base case, if \(n = 1\) or \(n\) is prime, then we’re done, otherwise, \(n = ab\) where \(a,b > 1\) and \(a, b < n\) (by the definition of prime). Since \(a\) and \(b\) are less than \(n\), then by the induction hypothesis both \(a\) and \(b\) are products of primes so \(a = p_1p_2...\) and \(b=q_1q_2....\). So now we can write \(n = p_1p_2...q_1q_2...\). \(\ \blacksquare\)
To show uniqueness, the need the following key result
Proof
Suppose that \(p \mid ab\). To prove such an argument, we will assume that \(p \not\mid a\) and show that \(p \mid b\). Since \(p \not\mid a\), then we know that \((p,a) = 1\). Therefore, for some integers \(x\) and \(y\), we have \(ax + py = 1\) (By Euclid). Now multiply this by \(b\)
\(p \mid ab\) and \(p \mid p\). Therefore, \(p \mid b\). \(\ \blacksquare\)
Proof (first version, uniqueness)
Suppose that \(p\) is prime and it can be written as the following products of primes
Then \(p_1\) must divide \(q_1q_2 \cdots\). But by the previous proposition, \(p_1\) must divide at least one of the primes \(q_1\),\(q_2\) and so on. So \(p_1 \mid q_i\) for some \(i\). But \(q_i\) is prime so \(p_1 = q_i\). We can now eliminate these two factors from both products and repeat this process until we’re done. So the factorization is unique up to order. \(\ \blacksquare\)
A similar result can be obtained for polynomials over a field like the real numbers. so if \(f(x) = a_0+a_1x+...\), then \(f(x)\) can be written as a product of constant polynomials and irreducible polynomials and this is unique up to order. In general though uniqness is not taken for granted. There are many examples where the factorization is not unique. Next, we see some examples of this
Example 1
Take the real numbers \(R = \{x \in \mathbb{R} \mid x \geq 1\}\). We can multiply any two real numbers in \(R\) and get another real number. For any element \(a \in R\), the inverse \(\frac{1}{a}\) only exists in \(R\) if \(a = 1\). So the units in \(R\) is just \(\{1\}\). What about primes in \(R\)? We earlier defined a prime to be an element such that if \(p = ab\), then either \(a\) is a unit or \(b\) is a unit. But notice here that given any \(a\), we can write \(a = \sqrt{a}\sqrt{a}\). So \(a\) is a product of two non-units. So \(a\) can’t be prime. So we don’t have primes here.
Example 2
Consider the integers \(1, 5, 9, 13, 17, 21, 25, 29...\). These integers are of the form \(4n+1\). This set is closed under multiplication since \((4n+1)(4m+1) = 4(mn+m+n) + 1\). What are the primes here? 1 is a unit. The elements 5, 9, 13, 21 are prime. But \(25 = 5 \cdot 5\) so it’s not prime. Moreover, every number in this set can be written as a product of “primes”. But this product is not unique because for example \(9 \cdot 49 = 21 \cdot 21\).
Example 3
Take functions over the real numbers. This set is closed under multiplication, addition and subtraction. Take the function \(x = (\sqrt{x})^2 = (\sqrt[4]{x})^4\). We can keep going on by splittong this further so we can see here that we don’t get a product of primes since none of these factors are units.
Example 4
Consider the numbers of the form \(m+n\sqrt{-5}\) where \(m\) and \(n\) are integers. In this system we have \(6 = 2 \cdot 3 = (1+\sqrt{-5})(1-\sqrt{-5})\). So we don’t have unique factorization in this system. (Note that numbers of the form \(m + n\sqrt{-1}\) (The Gaussian Integers) do have unique factorization. Note here that the units here are \(\{-1,1,i,-i\}\)).
Infinitely Many Primes
Next, we prove that there are infinitely many primes. The proof is also due to Euclid.
Proof
Suppose not. Then, we have a finite set of primes \(p_1, p_2,...,p_n\). Now, consider the number \(u = p_1p_2...p_n + 1\). Since \(u\) is not prime, then it can be written as product of primes and so at least one prime divides \(u\). Suppose \(p_i \mid u\). Now, consider \(u - p_1p_2...p_n = 1\). We know that \(p_i \mid u\) and we know that \(p_i \mid p_1p_2...p_n\). Therefore, \(u - p_1p_2...p_n\) must also divide \(p_i\). However, this means that \(p_i \mid 1\) and that’s impossible since \(p_i > 1\). So no prime in \(p_1,...,p_n\) can divide \(u\). Then, \(u\) itself must be a new prime or there are prime numbers not listed in the finite set. This is a contradiction. Thus, there are infinitely many primes. \(\ \blacksquare\)
Euclid's Method to Generate Primes
Based on the proof given above. Suppose now we use this method to generate primes so
Note here, that the product \(2 \cdot 3 \cdot 7 \cdot 43 + 1\) is not prime. Therefore, it is important to realize that multiplying primes and adding 1 doesn’t necessarily generate a prime.
But what about multiplying consecutive primes and then adding 1? does that always generate a prime? We can analyzing the first few cases as follows
So we can see here that \(2 \cdot 3 \cdot 5 \cdot 7 \cdot 11 \cdot 13 + 1\) is definitely not a prime. It’s important to note that this doesn’t contradicts Euclid’s proof as \(59\) and \(509\) are primes not in the original product.
Another thing to think about is that suppose we use Euclid’s method to generate primes. We saw above that we got \(2, 3, 7, 43, 13,....\). The question is: Do all primes appear in this list? This is an incredibility difficult question but the answer is almost certainly yes. Why? For example, does 101 appear in this list?
The chance of 101 appearing at step \(n\) is \(\frac{1}{101}\). Why? At step \(n\), we generate the \(n\)th prime in the list. For this number to be divisible by 101, this means that it leaves a remainder of 0 when divided by 101 (We can also describe this with module, There are exactly 101 classes of \(N (\bmod 101)\)). If we assume this number is completely random, then the chance of getting a remainder of 0 when divided by 101 is exactly \(\frac{1}{101}\)
Now, the chance of this number not appearing at step \(n\) is \(1 - \frac{1}{101}\). Therefore, the chance of it not appearing in any step up to the \(n\)th step is \((1 - \frac{1}{101})^n\). When \(n\) is sufficiently large, then this probability become almost 0.
Can we answer this definitely? no, we don’t know of way to prove this statement, that Euclid’s method generates every possible prime number. The professors makes a note here that that Number Theory is a subject where any fool can ask questions that nobody knows how to answer! there are many questions like this where no one knows the answer to.
Infinitely Many Primes of a Certain Form?
By looking at prime numbers, we notice that the last digit is \(3, 5, 7\) or \(9\) (excluding the prime numbers 2 and 5). Are there infinitely many primes with last digit 1? In other words, are there infinitely many primes of the form \(10n + 1\)? The answer is in fact YES! This is a famous result and the proof is given by Dirichlet. We’ll study this proof later. But for now, we’ll study a few easier variations of this result.
Are there infinitely many primes of the form \(4n+3\)? To answer this, we can do something similar to Euclid’s proof. Claim:
Proof: Suppose there are only finitely many primes \(p_1,...,p_k\) of the form \(4n+3\). Consider the number \(u = 4p_1p_2....p_k - 1\). \(u\) is not divisible by any prime \(p_1,...,p_k\). Similar to the earlier proof, because if it did divide any of them, then this means that \(p_i \mid -1\) which is a contradiction. So either \(u\) is a prime. In this case it is of the form \(4m - 1 = 4(m-1)+3\) so we have a new prime of the from \(4m+3\). Or, \(u\) is a composite so there is at least a prime factor dividing. In this case, it is not possible to have all the prime factors of the from \(4m+1\) since the product of such factors is also of the from \(4m+1\). We also can’t have primes of the from \(4m+2\) since this is even. Then, we must have at least one factor of the from \(4m+3\) that is not in the original list of primes. \(\ \blacksquare\).
Exercise: There are infinitely many primes of the from \(3n+2\). What about primes of the form \(4m + 1\)?
The problem here is that we can’t use the same trick/argument we used last time because the product of primes of the from \(4m+3\) isn’t necessarily of the form \(4m+3\) so we need another argument. Here we use the fact that if a prime divides \(m^2 + 1\), then \(p = 2\) or \(p = 4n+1\) (we will prove this later in the course). But before we use this fact, it’s always good to see a few examples of what this looks like so
Proof
So suppose there are only finitely many primes \(p_1,p_2,...,p_k\) of the form \(4n+1\). Now, consider the product \(u = (2p_1p_2...p_k)^2 + 1\) (Side note: Why this? well we want to use that special fact and also squaring \(p_1...p_k\) and adding 1 might give us something that is divisible by 2 so to make sure that doesn’t happen, we will stick 2 inside the squared product). So now we know that none of the primes \(p_1,p_2,...p_k\) can divide this product since they will have to divide 1 and that’s impossible. Moreover, all the factors of \(u\) must be either 2 or of the form \(4n+1\) by the fact that we didn’t prove yet. \(\ \blacksquare\)
We can use the same technique to also show the following
Proof
Similar to before, suppose there are only finitely many primes \(p_1,...,p_k\) where the last digit is 3 or 7. Now consider \(u = (10p_1....p_k) + 3\). We can show that any factor of this \(u\) must have its last digit be 3 or 7. Prof. Richard notes that the proof is much harder if we wanted to prove that there are many infinitely primes with last digit 3 only or last digit 7 only. It’s much harder to separate the two.
Gaps Between Primes
Observe the first few prime numbers again
We see gaps of 1, 2, 4, 6 and the question here is can we bound gaps? The answer is no. To demonstrate this, Consider the consecutive composite numbers
These are \(n-1\) consecutive composite numbers. These are composite because \(n! + k\) is divisible by \(k\) if \(1 \leq k \leq n\). Therefore, there is a gap of at least \(n-1\) numbers between the prime \(p \leq n!\) and the next prime \(q > n! + n\). We can see here that we can make the gap as large as we want. This demonstrates that there isn’t a bound.
Also notice here that \(n-1\) is slightly less than \(\log(n!)\). It turns out the “average” size of gap between prime numbers is actually \(\log(n)\) which follows from the prime number theorem which will be discussed later in the course.
There is a breakthrough by Zhang that says the gap is sometimes \(\leq 70,000,000\) for large \(n\). That there are infinitely many primes of pairs of primes \(p\) and \(p'\) such that \(|p - p'| \leq 70,000,000\). There is also the Twin Prime Conjecture which claims that there infinitely many primes that differ by two. But unlike Zhang’s this one remains unproven.