Prime numbers are the multiplicative building blocks of all whole numbers. In fact, we will see that every whole number can be decomposed into a product of (maybe repeated) prime numbers in exactly one way. Letβs define a prime number first:
A prime number is a whole number that has exactly two factors; namely \(1\) and itself. If a natural number \(n\) is not prime, and not \(1\text{,}\) we say that \(n\) is composite.
Itβs worth noting here that using this definition, \(1\) is not a prime number. Most mathematicians decided to follow this convention since \(1\) behaves quite differently to other prime numbers, and therefore to avoid frequently talking about \(1\) as a special case for various results, it was more convenient to exclude \(1\) from the list of prime numbers.
The number \(7\) is prime since the only numbers that are factors of \(7\) are \(1\) and \(7\) itself. Every other number does not divide evenly into 7.
Letβs try and come up with a list of all prime numbers less than \(100\text{.}\) We could do this for all primes below any number, but we choose 100 for space reasons.
Weβll cross off \(1\) since we know that it doesnβt have exactly two factors; its only factor is itself. So now we know that the next largest number, \(2\text{,}\) must be prime since it has \(1\) and itself as a factor, and there are no other numbers smaller than \(2\text{.}\) So we circle \(2\) and cross off all numbers that have \(2\) as a factor.
Now we can go to the smallest number that remains, \(3\text{,}\) and circle that since it must be prime; 2 is not a factor and there are no smaller prime numbers. Like before we circle \(3\) and cross off all other multiples of \(3\text{:}\)
We can continue this process until all numbers are either circled or crossed off. Before looking below, try this yourself and check that you get the same list of primes as below:
This process is very old, and in fact is called the sieve of Eratosthenes, after the Greek mathematician Eratosthenes of Cyrene, of whom this method is attributed to.
What can you say about the amount of smaller prime numbers compared to the number of larger (at least closer to 500) prime numbers? Why do you think this is the case?
On the same chart, highlight all multiples of 6. What can you say about how prime numbers relate to multiples of 6? Formulate your conjectures in terms of remainders.
Try and prove the conjecture you made in the previous part. Hint.
Show that prime numbers cannot have other remainder than the ones that you conjectured. Remember, if you can find a factor of your numbers that isnβt \(1\) or itself, then the number isnβt prime.
Looking at the sieve above, it looks like prime numbers get more "rare" the higher up we go. So a good question to ask is whether we eventually "run out" of prime numbers, or whether there are infinitely many. Letβs explore this idea a little bit:
First, we need a small result to help us out. In math, we call a small result that helps us justify a larger result a lemma.
Lemma7.3.4.
Let \(a_1,a_2 \ldots a_n \in \mathbb{N}\) be \(n\) numbers, and let \(a_* = a_1 \times a_2 \times \ldots \times a_n\text{.}\) Then for each \(a_i\) from \(a_1\) to \(a_n\) we have that \(a_i \nmid (a_*+1)\text{.}\)
By LemmaΒ 7.3.4 we know that \(2 \nmid 7\) and \(3 \nmid 7\) (although this is pretty obvious anyway). So \(a\) is not divisible by any prime numbers in our set \(A\text{.}\) This means that \(a\) is either prime itself, or a product of other primes that arenβt already in \(A\text{.}\) In this case \(a=7\) is prime.
We now redefine \(A\) to include our new prime (or primes if \(a\) had other prime factors.) So in this case now \(A:=A \cup \{7\} = \{2,3\} \cup \{7\} = \{2,3,7\}\text{.}\)
We then repeat the procedure with the new \(A\) to obtain \(a=2\times 3\times 7+1 = 43\text{,}\) which itself is prime, so we include it in our set as well; \(A=\{2,3,7,43\}\text{.}\)
Letβs do this again: now \(a=2\times 3 \times 7 \times 43+1 = 1807\text{.}\) You can check that \(1807=13 \times 139\) which are both prime, so we can add \(13\) and \(39 \) to our set: \(A=\{2,3,7,13,39,43\}\text{.}\)
We can continue this process, and at each step we will form a number \(a\) that has no numbers in \(A\) as a factor, so we will be able to add at least one more prime number (either \(a\) itself if it is prime, or the prime factors of \(a\) if it is not) to our set.
As our set grows by at least one number every iteration of this process, we know we can always include at least one more prime number in our set. So we will never run out of prime numbers, and thus there are infinitely many prime numbers.
Some good questions come out of the previous exercise: first, will this list eventually include all prime numbers? Secondly, if we have a large number (like \(1807\) or even bigger,) how can we determine if this number has any prime factors? The second question we will answer in the next subsection of this section.
Later, we will be very careful and learn how to check that these are all of the possible ways of factoring 72 into two numbers. But it is not too hard to check in this case (do you see how to do this?) Letβs plot these pairs on a number line to see if we notice something:
It looks like the paris are approaching some point, letβs call it \(P\) between 8 and 9, plotted above, and that there is always one number of the pair thatβs greater than \(P\text{,}\) and one that is less than \(P\text{.}\)
From the exercise above, factoring any number \(n\) into two factors, it looks like our factorizations approach the positive square root of \(n\) (usually written \(\sqrt{n}\)). In a later section we will explore square roots, and other roots, in more detail. The key observation here is that in any pair of factors of \(n\text{,}\) one factor is always greater than or equal to \(\sqrt{n}\) and the other factor is less than or equal to \(\sqrt{n}\text{.}\) Letβs write this as a lemma:
Let \(n \in \mathbb{N}\text{.}\) If \(n=a\times b\) for some \(a,b \in \mathbb{N}\) where, say, \(a \geq b\text{,}\) then \(a \geq \sqrt{n}\) and \(b \leq \sqrt{n}\text{.}\)
We are going to show this result is true using a proof by contradiction. As in part 3 of SubsectionΒ 1.2.2, we are going to pretend that there is a counterexample to our conditional statement (that is, the only situation where \(P \to Q\) is false; when \(P\) is true and \(Q\) is false.) We will show that if we are in this case, then mathematics "breaks" and we end up with something that is never true. This means that there are no counterexamples to our statement, so it must always be true. In our case, we will end up with showing that \(n > n\text{,}\) which is always false; of course, no number is strictly greater than itself!. The idea will be that if we multiply two number bigger than \(\sqrt{n}\) together, we must get a number bigger than \(n\text{.}\)
Assuming that the if-part is true, let \(n=ab\) be a factorization of \(n\) into two factors, where \(a \geq b\text{.}\) Letβs also assume that the then-part is false; that either both
\begin{equation*}
n = (\sqrt{n})(\sqrt{n})\text{.}
\end{equation*}
Since weβre assuming \(a > \sqrt{n}\text{,}\) if we replace one of the \(\sqrt{n}\) in the first expression with \(a\) we will obtain a larger product, so
\begin{equation*}
n = (\sqrt{n})(\sqrt{n}) > a(\sqrt{n}) \text{.}
\end{equation*}
Similarly, weβre also assuming \(b > \sqrt{n}\text{,}\) if we replace the other \(\sqrt{n}\) in the new expression with \(b\) we will obtain a larger product, so
\begin{equation*}
n = (\sqrt{n})(\sqrt{n}) > a(\sqrt{n}) > ab \text{.}
\end{equation*}
But we know that \(n=ab\) so we can replace the \(ab\) on the right hand side by \(n\text{.}\) So
\begin{equation*}
n = (\sqrt{n})(\sqrt{n}) > a(\sqrt{n}) > ab = n.
\end{equation*}
So if we look at the (in)equation above, we have just showed that \(n > n\text{.}\) Since this is never true, then there are no counterexamples to our original statement (at least in the first case).
The case where we assume that \(a,b < \sqrt{n}\) is very similar, and is left as an exercise to you. See if you can modify the case above to be a proof for this case.
We can use the idea above to help us, somewhat efficiently, determine if a number is composite. Indeed, if \(n\) is a composite number, it must have a pair of factors \(1 < a,b < n\) (and say that \(a \geq b\)) where \(n=ab\text{,}\) and by LemmaΒ 7.3.9 it must be that \(b \leq \sqrt{n}\text{;}\) that is, every pair of factors of \(n\) has one of the factors that is no bigger than \(\sqrt{n}\text{.}\) So we can only worry about these factors, since the larger factors are paired with a smaller one.
We can do even better than checking if all numbers less than \(\sqrt{n}\) are factors of \(n\text{.}\) Weβll show that you only need to check whether the prime numbers less than \(\sqrt{n}\) are factors of \(n\text{.}\) First, we show that every composite number has at least one prime factor, and then we will show that the smallest non-unit (that is, not 1) factor of \(n\) is indeed a prime number.
Similar to the previous proof, letβs show this by contradiction. Weβll pretend we have a counterexample (in fact the smallest counterexample), and show that something "breaks", so thus there must be no counterexamples. The contradiction weβll have is that even though we picked the smallest counterexample, weβll find one thatβs smaller.
Let \(n\) be the smallest composite number (if-part true) that has no prime factors (then-part false). Since \(n\) is composite and has no prime factors, then \(n=ab\) for some composite numbers \(a,b\text{.}\) But all proper factors of a number are between \(1\) and \(n\) exclusive (that is \(1 < a,b < n\)). But since \(n\) has no prime factors, neither can \(a\) or \(b\text{,}\) since if \(a=pc\) for some prime number \(c\) then \(n=ab=(pc)b=p(cb)\text{,}\) and thus \(p\) is a factor of \(n\text{.}\) But this means that \(a\) is a smaller composite number than \(n\) with no prime factors, so \(n\) isnβt the smallest counterexample, even though we picked it to be. This means that there is no smallest counterexample, and thus no counterexample to our statement. So \(n\) must have at least one prime factor.
To show that the smallest factor of \(n\) is always a prime number, we do a very similar argument. Weβll leave it as an exercise, but we state the theorem.
Theorem7.3.11.
If \(n\) is composite, then the smallest proper factor of \(n\) is a prime number.
Putting this all together, we know that if a number \(n\) is composite then there is a prime number \(p \leq \sqrt{n}\) such that \(p \mid n.\) So to check that \(n\) is composite, all we need to do is check if each prime number up to \(\sqrt{n}\) is a factor of \(n\text{.}\) Itβs more common to talk about testing if a number *isnβt* composite, so we will phrase the test below in that language:
A number \(n \in \mathbb{N}\) where \(n \geq 2\) is prime exactly when it has no prime factors \(p \leq \sqrt{n}\text{.}\) We can test for primality using this following steps:
2. For each prime number \(p \leq p_*\text{,}\) determine if \(p \mid n\text{.}\) If you find such a prime \(p\text{,}\) stop. Then \(n\) is composite. Otherwise go to the next step.
First, we find the largest prime \(p_* \leq \sqrt{n}\text{.}\) If we have access to a calculator, we know that \(\sqrt{403} \approx 20\text{.}\) But if we do not, we can square primes and "sandwich" 403 between these squares. We know that \(19^2=361\) and the subsequent prime \(23^2=529\text{.}\) So this means that \(19 \leq \sqrt{403} \leq 23\text{,}\) and \(19\) is the largest prime that is less than or equal to \(\sqrt{403}\text{.}\)
We now test the divisibility of each prime up to \(19\) into \(403\text{.}\) If none of these primes are a factor of \(403\) then by our test for primality, \(403\) is prime. We will do each prime individually, and when we have a divisibility rule to help us, we will use that.
13: By division, we know that \(403 \div 13 = 31\text{.}\) So indeed \(13 \mid 403\) and \(403=13 \times 31\text{.}\) We have found a prime factor of \(403\) and thus by our test for primality, \(403\) is not prime (and we have a factorization of it too!)
We need to find the greatest prime less than or equal to \(\sqrt{293}\text{.}\) Without a calculator, we can bound \(\sqrt{293}\) between two consecutive primes, or put another way, bound \(293\) between two squares od primes.
We have checked the divisibility of all primes up to and including \(17\text{.}\) Since we have found that none are factors of \(293\) our test for primality guarantees us that \(293\) is prime.