Section 12.1 Finding More Primes
Subsection 12.1.1 Fermat primes
Here is an interesting historical example. Recall (Subsection 11.5.1) that our friend Pierre de Fermat thought that numbers of the formDefinition 12.1.1.
We call numbers of the form
xxxxxxxxxx
for n in [0..7]:
pretty_print(html("If $n=%s$, then $2^{2^n}+1=2^{2^%s}+1=%s$ factors as $%s$"%(n,n,2^(2^n)+1,factor(2^(2^n)+1))))
Subsection 12.1.2 Primes from Fermat numbers
However, we can at least prove what seems obvious in the computation after Definition 12.1.1 β namely, that lots of primes arise as factors of Fermat numbers, even whenLemma 12.1.2.
Suppose
Proof.
Multiply and/or apply a little induction. (See Exercise 12.7.1.)
Example 12.1.3.
For instance,
which corresponds to the factorization
Similarly,
which corresponds to the factorization
Proposition 12.1.4. Fermat numbers are coprime.
Proof.
First, notice that any two Fermat numbers are very closely related to each other; if \(n<m\text{,}\) then \(F_n-1\) divides \(F_m-1\text{.}\) In fact, one is a power of the other:
Because of this, using Lemma 12.1.2 with \(j=2^n\) and \(k=2^{m-n}\) (which is certainly even), we get
This implies the divisibility relationship
so any number \(d\) that divides \(F_n\) also divides \(F_m-2\text{.}\) Now we do a standard trick (see also Exercise 2.5.6). Combine all of the above facts to see that any divisor of \(F_n\) which also divides \(F_m\) must divide \(F_m-(F_m-2)=2\text{,}\) so a common divisor of \(F_n\) and \(F_m\) could only be two or one.
But both Fermat numbers are odd, so the gcd must be 1.
Subsection 12.1.3 Mersenne primes
Another early attempt at finding big primes was an idea of Marin Mersenne.Historical remark 12.1.5. Marin Mersenne.
Mersenne was a Minim monk who not only acted as a clearinghouse for scientific knowledge in early 17th century France (particularly between Pascal, Fermat, Descartes, Roberval, and their friends) but also wrote major theological and music theoretical treatises of his own. See Figure 19.4.12.
Definition 12.1.6.
In general, numbers of the form
xxxxxxxxxx
for p in prime_range(100):
pretty_print(html("If $p=%s$, then $2^p-1=2^{%s}-1=%s$ factors as $%s$"%(p,p,2^p-1,factor(2^p-1))))
Historical remark 12.1.7. GIMPS.
You can help the world search for more Mersenne primes if you leave your personal computer on and connected to the Internet, via the Great Internet Mersenne Prime Search (GIMPS). Random computers in labs at the University of Central Missouri and UCLA have found some of the largest known primes this way.
The most recent one (as of this writing in January 2021) was found in December 2018! The largest known such primes are very large; this one has nearly twenty-five million digits, and the folks at Numberphile made a very amusing video unwrapping a book containing a previous record holder of βonlyβ twenty-two million digits. GIMPS even won a monetary prize for finding these huge primes; they shared it with many of the people who made it possible.
Historical remark 12.1.8. The Skylake bug.
These primes are far too large, and are not common enough, to use for most serious applicationsβ3β, but nonetheless they help us investigate ideas about primes. A less obvious but interesting application is that searching for very large primes can also help more mundane hardware testing.
A good example of this is that computing the GIMPS program uncovered a bug in a major Intel chip. Number theory can push our hardware (and software!) beyond our imagination. (See also Historical remark 22.3.9.)
Algorithm 12.1.9. Lucas-Lehmer test.
Let
Do this
Example 12.1.10.
With
modulo is modulo is modulo is
And of course
xxxxxxxxxx
def _(p=(71,prime_range(100))):
test = 4
num = 2^p-1
for i in range(p-2):
test=(test^2-2)%num
pretty_print(html("The test says "+str(bool(test==0))))
pretty_print(html("And in fact $2^{%s}-1=%s$ primality is "%(p,num)+str(is_prime(num))))
Subsection 12.1.4 Primes from Mersenne numbers
We can prove the lesser result that Mersenne numbers are coprime, which (just as with the Fermat numbers) can give us a lot of interesting prime factors.Proposition 12.1.11. Mersenne numbers are coprime.
Mersenne numbers
Proof.
By way of contradiction, let \(d>1\) be the gcd of the two numbers \(2^p-1\) and \(2^q-1\text{.}\) Let's investigate the order of \(2\neq 1\) in \(U_{d}\text{.}\) (Before reading more, think about why \(2\) is even in this group.)
By definition of divisibility,
By group theory (use Theorem 8.3.12) we know that \(2^k\equiv 1\) means that \(k\) is a multiple of the order \(|2|\) of the element \(2\text{.}\) Thus \(p\) and \(q\) both are multiples of \(|2|\text{.}\)
Since \(p\) and \(q\) are coprime, though, the only possibility for \(|2|\) is that \(|2|=1\text{.}\) This is a contradiction, so our assumption that \(d>1\) was wrong.