Section 22.2 Sequences and Primes
ΒΆSubsection 22.2.1 Primes in sequences
ΒΆThere is an interesting question implicit in the prime races. To legitimize doing the first prime race, we proved that there are infinitely many primes of the forms 4k+1 and 4k+3. However, we then proceeded to do prime races for several other such forms. Is it legitimate to do so? The answer is yes, as proved in this major theorem of 1837 that introduced limiting and calculus methods to the study of number theory.Theorem 22.2.1. Dirichlet's Theorem on Primes in an Arithmetic Progression.
If gcd(a,b)=1, then there are infinitely many primes of the form ax+b for x an integer.
Proof.
The proof of this theorem is far beyond the level of this text, but [C.4.6] is a standard resource for this.
xxxxxxxxxx
def _(a=8,b=7,n=100):
if gcd(a,b)!=1:
pretty_print(html("Oops! The progression won't have many primes if"))
pretty_print(html("$a$ and $b$ share a common factor!"))
else:
pretty_print(html("Primes of the form $%sx+%s$ up to $%s$:"%(a,b,n)))
for x in prime_range(n):
if x%a==b:
print(x)
Subsection 22.2.2 Sequences in primes
ΒΆWe can also look at the opposite question. Instead of considering whether primes exist in a given arithmetic progression, are there arithmetic progressions made of solely of primes?Question 22.2.2.
Can you get a (finite) sequence of the form
where all entries are prime?
3, 5, 7 is an arithmetic progression of length 3, where a=2.
41, 47, 53, and 59 is an arithmetic progression of length 4, where a=6.
xxxxxxxxxx
def _(p = prime_range(200), n=110):
L = [p,p+n,..p+4*n]
for z in L:
if is_prime(z):
print(z)
else:
print(factor(z))
break
Fact 22.2.3.
There is such a sequence of length 10 starting at 199, with differences of 210.
Question 22.2.4.
Can find arbitrarily long such sequences in the primes?
Ο(100)/100=1/4=0.25
Ο(200)/200=0.23
Ο(1000)/1000=0.168, or under 17%.
Ο(1000000)/1000000β0.0785, or under 8%.
xxxxxxxxxx
difference=81292139*2*3*5*7*11*13*17*19*23
start=224584605939537911
for n in [0..26]:
print(start+n*difference,is_prime(start+n*difference))
Fact 22.2.5.
A sequence of length k must occur before
Definition 22.2.6.
For a prime p, we call the primorial the number
where the βp sharpβ or βp hashββ1βOfficially, this should be called an octothorp(e). denotes p primorial.
First, for some fixed p, compute a large set of primes of the form aβ p#+1, keeping track of the a values in question.
Next, find arithmetic progressions among the values of a from your list (not the values of aβ p#+1).
If you find a bunch of a values in a progression of the form k+ββ n, then you've also found a progression of primes of the form (kβ q#+1)+(ββ q#)n.