
TL;DR
This paper introduces a simple method leveraging Farey sequences to efficiently generate various prime number sequences, offering a new approach to prime computation.
Contribution
It presents an elementary Farey sieve method for computing prime sequences, providing a novel technique compared to existing algorithms.
Findings
Efficient prime sequence generation demonstrated
Farey sequences effectively identify primes
Method simplifies prime computation processes
Abstract
An elementary method for computing various prime sequences using the sequence of Farey sequences is described.
| Name | Invocation |
|---|---|
| Primes | FareySieve[{#&}] |
| Twin Primes | FareySieve[{#&,#+2&}] |
| Prime Constellation | FareySieve[{#&,#+2&,#+6&}] |
| Sophie Germain Primes | FareySieve[{#&,2#+1&}] |
| Gaussian Primes | FareySieve[{#&,4#+3&}] |
| Cunningham Chain | FareySieve[{#&,2#+1&,4#+3&}] |
| Dickson Chain | FareySieve[{#&,2#+1&,3#+4&}] |
| Star Primes | FareySieve[{6#(#-1)+1&}] |
| Shanks Primes | FareySieve[{#^2+1&}] |
| Shanks Twins | FareySieve[{(#-1)^2+1 &,(#+1)^2+1 &}] |
| Hardy-Littlewood Primes | FareySieve[{#^2+#+1&}] |
| Thabit Primes | FareySieve[{3*2^#-1&}] |
| Wagstaff Primes | FareySieve[{(2^#+1)/3&}] |
| Safe Primes | FareySieve[{#&,(#-1)/2&}] |
| Proth Primes | FareySieve[{2^#+1&}] |
| Kynea Primes | FareySieve[{(2^#+1)^2-2&}] |
| Mersenne Primes | FareySieve[2^#-1&] |
| Centered Heptagonal Primes | FareySieve[{(7#^2-7#+2)/2&}] |
| Centered Square Primes | FareySieve[{#^2+(#+1)^2&}] |
| Centered Triangular Primes | FareySieve[{(3#^2+3#+2)/2&}] |
| Carol Primes | FareySieve[{(2^#-1)^2-2&}] |
| Cullen Primes | FareySieve[{#2^#+1&}] |
| Double Mersenne Primes | FareySieve[{#&,2^(2^#-1)-1&}] |
| Euler Primes | FareySieve[{2^(2^#)+1&}] |
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAdvanced Mathematical Theories · Algorithms and Data Compression
The Farey Sieve
Scott B. Guthery
Abstract.
An elementary method for computing various prime sequences using the sequence of Farey sequences is described.
Key words and phrases:
Farey sequence, twin prime, prime constellation
2000 Mathematics Subject Classification:
11M26
1. Introduction
The Farey sieve associates counts with fractions in Farey sequences and uses these counts to characterize prime numbers.111“It is one of the clichés of mathematical history that it is disastrously easy even for an amateur to infer by induction results in the theory of numbers whose proof or disproof may be a century or more beyond the current capacities of mathematics.”E.T. Bell [2, p. 178]
1.1. A Recursion for the Farey Sequence
The Farey sequence is the sequence of irreducible rational numbers with arranged in increasing order.
If a rational number is represented as an ordered pair where is the numerator and is the denominator of , then the Farey sequence of order can be computed using the following recursion due to d’Ocagne [15]:
[TABLE]
where and .
1.2. A Recursion for the Sequence of Farey Sequences
The original method for building the Farey sequence from , the one described by Charles Haros ([13], [14]) fifteen years before it was noticed by its namesake, John Farey [9], is to insert between and whenever . is the mediant of and .
While this is a handy method of generating Farey sequences using paper and pen – which is what Charles Haros was doing when he discovered this application of the mediant – the method does not lend itself to the analysis of the properties of Farey sequences as a function of the order, .
Another way to generate directly from is keep track of where and when new elements appear. Let be an element of and define
[TABLE]
is a periodic counter associated with the fraction . It starts at when first appears in the sequence of Farey sequences, namely in . As increases it counts down to and then starts over at . Whenever the counter resets, that is when it changes from in to in a new fraction appears on the right of in , in particular one with denominator . Otherwise, the next larger fraction is the same.
Using the Farey set can be expressed recursively in terms of as follows:
[TABLE]
where . This isn’t a closed form for but it offers a slight improvement on Haros’ step-at-a-time mediant algorithm. In particular based on the current sequence it lets us look ahead a number of steps to say when and where new fractions will be arriving.
The following properties of follow directly from its definition:
- i)
Starting Value: 2. ii)
Unique Values: 3. iii)
Cycle Time: If , then for 4. iv)
Reset: If , then . 5. v)
Steps to Reset: If , then .
The two most useful properties in the following are properties and . Property says that the counter values associated with the fractions having the same denominator are all different. Property says that counts the number of steps forward from until a new (greater) fraction appears to the right of .
We will see that if moving from to causes the reset of a fraction of every denominator from to then is a prime number.
1.3. Functions of the Sequence of Farey Sequences
The above recursion for generating the sequence of Farey sequences may be used to describe properties of Farey sequences as a function of the order of the sequence.
For example, the distance between a Farey fraction with denominator in and the next larger Farey fraction in as a function of is given by
[TABLE]
As another example, one can express the order index of an element of the Farey sequence as a function of and as follows. Let denote the order index of in . Then the order index of in for is given by
[TABLE]
The result of Franel [10] regarding the equivalence of a property of the sequence of Farey sequences and the Riemann Hypothesis can be written using the above notation as
[TABLE]
where is the Euler summatory function.
Franel’s result says intuitively that the Farey sequence encodes the prime numbers and thus it is not surprising that the Farey sequence can be used to study properties of the prime numbers. What is perhaps a bit surprising is that the Farey sequence encodes the prime numbers without ever mentioning them.
1.4. The Farey Sieve
For a Farey fraction , let
[TABLE]
is the value of starting at for which . Define
[TABLE]
is the (countably infinite) set of all such that there is a Farey fraction with denominator and in . Finally, define
[TABLE]
is the (countably infinite) set of all such that for each , , there is a Farey fraction with denominator and in .
In these collections of values which particular Farey fraction with denominator satisfies a condition is immaterial. All that matters is that there is one. From property above there is at most one.
2. Prime Generation
But before we can compute and with only primes we must show that the sequence of primes can be constructed using the sequence of Farey sequences. The only a priori property of the primes employed in this construction is a weak one, Bertrand’s Postulate ([3], [4], [17], [7]). This postulate states that there is always a prime between and . In particular, the sequence of prime numbers is generated without appealing to the notion of factorization.
Lemma 1**.**
* is a prime if and only if .*
Proof.
if and only if there is a fraction with denominator and in for each , . In this case and if and only if is a prime. ∎
Theorem 1**.**
Let be a prime and set
[TABLE]
Then is the next prime after .
Proof.
Consider . From the definition of , and there is an with denominator in such that . If in addition then .
If then there is with . Then .
To summarize, for each such that , there is an with denominator in such that .
Since by Bertrand’s Postulate we have that there is a in with and denominator every between and . Therefore and is a prime by Lemma 1.
Since , for each , , there must be at least one , , for which there is no fraction with denominator and in . Therefore, is not prime and is the next prime after . ∎
3. Farey Sieving
The following lemmas help construct efficient sieves.
Lemma 2**.**
If is a prime factor of then .
Proof.
Each in is of the form
[TABLE]
where and . Since , where . As is prime so
[TABLE]
is in . ∎
Lemma 3**.**
If is the set of prime factors of then
[TABLE]
Proof.
From Lemma 1, If then by the Chinese Remainder Theorem, there is a such that so . ∎
Lemma 4**.**
For prime ,
Proof.
There are fractions with denominator each with a different value that is between and therefore exactly one of these values is always missing; namely . ∎
As a result of these three lemmas we have
[TABLE]
4. Twin Prime Generation
The twin prime conjecture is a special case of a conjecture due to Polignac [5] who posited that there are an infinite number prime pairs, and , such that where is a fixed even number. The case when is called the twin prime conjecture.
Lemma 5**.**
* is the lesser of a twin prime if and only if*
[TABLE]
Proof.
is a prime since .
Further since we have along with and . The condition
[TABLE]
ensures that for . Therefore for . That is,
[TABLE]
so is a prime. ∎
Twin Prime Conjecture Let be the lesser of a twin prime and set
[TABLE]
Then is the lesser of the next twin prime after .
From the above lemmas, for prime and ,
[TABLE]
so is never null and always exists.
5. Prime Constellations
A sequence of integers is called an (admissible) prime constellation if for each prime , there is some residue class modulo which contains none of the . Hardy and Littlewood [12] conjectured that if is a prime constellation then there are infinitely many integers such that are all prime.
Table 1 lists some examples of prime constellations. The first entry in this table describes the prime numbers and the second entry describes prime pairs. Table 2 lists some instances of the fourth entry in Table 1, the prime constellation . The sequence of primes
[TABLE]
is described by the eighth entry, . For many more examples see [8], [11], [16], and [19] as well as various web sites devoted to prime numbers.
In this note we use the Farey sequence to easily compute instances of a given prime constellation. The method is then used to demonstrate that for any prime constellation there are an infinite number of such instances.
The sequence of -tuples satisfying a prime constellation can be generated by taking the intersection over the constellation. The above result for twin primes can be easily extended to include prime constellations.
Prime Constellation Conjecture Let be the minimum prime of a -tuple described by the prime constellation and set
[TABLE]
Then is the minimum prime in the next -tuple described by the constellation
6. Prime Function Values for a Common Argument
Dickson conjectured in [6] that given a family of linear functions with integer coefficients and :
[TABLE]
then there are infinitely many integers for which these are simultaneously prime unless there is a prime which divides the product of these for all .
Dickson Conjecture. Let be the minimum prime of a -tuple of primes described by the linear coefficients and set
[TABLE]
Then is the minimum prime in the next -tuple described by the linear coefficients.
Schinzel-Sierpinski [18] and Bateman-Horn [1] proposed the following generalization of the conjectures of Bunyakovskii, Goldbach, Hardy-Littlewood, Dickson, Shanks and others prime function values for a common argument.
Hypothesis H. Let be a positive integer and let be irreducible polynomials with integral coefficients and positive leading coefficients such that there is not a prime which divides the product
[TABLE]
for every integer . Then there exists an integer such that are all prime numbers.
7. Mathematica Code for the Farey Sieve
The following Mathematica® notebook implements the Farey sieve for arbitrary sets of functions. Table 3 lists invocations of this notebook to generate various familiar prime sequences.
IntegerTable = {};
FunctionSieve[ems_, f_] := Module[{i, iMax, d, l = {}, emsMax = ems[[Length[ems]]]}, d = Map[f, IntegerTable] - 1; iMax = LengthWhile[d, # <= emsMax &]; For[i = 1, i <= iMax, i++, If[MemberQ[ems, d[[i]]], l = Append[l, i]; ]; ]; l ]
FareySieve[f_, n_: 6, size_: 1000] := Module[{i, j, d = 2, l, tp = 2, ems, fun, k = n, p, t}, l = IntegerTable = Table[i, {i, 2, size}]; While[k > 0, ems = Fms[d]; For[i = 1, i <= Length[f], i++, l = Intersection[l, FunctionSieve[ems, f[[i]]]]; ]; If[Length[l] == 0, Print["Null Intersection"]; Break[] ]; If[ l[[1]] + 1 != tp, tp = l[[1]] + 1; t = {}; For[i = 1, i <= Length[f], i++, p = f[[i]][tp]; t = Append[t, {p, PrimeQ[p]}]; ]; Print[t]; k--; ]; d++; ]; ]
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] Paul T. Bateman and Roger A. Horn, A heuristic asymptotic formula concerning the distribution of prime numbers , Mathematics of Computation 16 (1962), 363– 367.
- 2[2] Eric Temple Bell, The problem of liouville’s theorems on arithmetical quadratic forms , Scripta Mathematica 13 (1947), no. 3-4, 177–185.
- 3[3] Joseph Louis François Bertrand, Mémoire sur le nombre de valeurs que peut prendre une fonction quand on y permute les lettres qu’elle renferme , J. École Polytechnique (1845), 123–140.
- 4[4] Pafnuty Lvovich Chebyshev, Mémoire sur les nombres premiers , Mém. Acad. Sci. St. Pétersbourg (1850), 17–33.
- 5[5] Alphonse Armand Charles Marie Prince de Polignac, Six propositions arithmologiques deduites du crible d’eratosthene , Nouvelles Annales de Mathematiques 8 (1849), 421–429.
- 6[6] Leonard Eugene Dickson, A new extension of dirichlet s theorem on prime numbers , Messenger of Mathematics 33 (1904), 155–161.
- 7[7] Paul Erdös, A theorem of Sylvester and Shur , J. London Math. Soc. 9 (1934), 282–288.
- 8[8] Paul Erdös and Hans Ivar Riesel, On admissible constellations of consecutive primes , BIT 28 (1999), no. 3, 391–396.
