ON THE Kth EXTENSION OF THE SIEVE OF ERATOSTHENES

The Sieve of Eratosthenes has been recently extended by excluding the multiples of 2, 3, and 5 from the initial set, and finding the additive rules that give the positions of the multiples of the remaining primes. We generalize these results. For a given k we let the initial set S k consists of natural numbers relatively prime to the first k primes, and find the rules governing the positions of the multiples of the remaining elements.

One of several algorithms from the Greeks that, has survived the test of time, due to its simplicity and efficiency, is the Sieve of Eratosthenes.Given an initial set of positive integers S {2, 3, 4,...,N}, the prime numbers in S can be found iteratively by first crossing out all the multiples of 2 larger than 2 in S; then, in each subsequent step, the multiples of the smallest remaining number p not previously considered are crossed out.The process continues while p < N. It should be noted that only prime numbers are used to sieve, and that the multiples of any number p are p units apart.
The advent of computers and the electronic transmission of information, with encrypting and testing techniques based on large primes, explains the enormous attention that the prime numbers have received during the last twenty-five years.The search for efficient algorithms to generate large tables of primes have produced impressive results such as Benelloum [1], Mairson [2], and Pritchard [3].Several improvements have been made to the Sieve by reducing the size of the initial set and by avoiding some duplication in the removal process.In this paper, we will justify and generalize these simplifications of the Sieve, which may prove to be of particular interest in parallel processing.
The original algorithm can be readily improved, to what we will call the first extension, by first letting the initial set, denoted Sa, consist of only odd numbers, and then crossing out the multiples of p from p2 on, starting with p 3. We remark that, in this first extension, the multiples of any number p can still be found by counting, since their positions in Sa are still p ,,fits apart.Iu the olh'st ieference to the Sieve commonly available in English, Nichomacus [4] states that Erato.thens was aware of this idea of starting with only odd numl)ers, and made use of it.In g'neral, no distinction is found in the literature between the original Sieve and the first extension (of I,hmth [5]).
In 1989, Xuedoug Luo [6] obtaimd a second extension of the Sieve ly also re,noving the ,nultiples of three f,o,n the initial set.denoted S. Three years later, a third extension was found by Quesada [7] by further removing the multiples of five from the set Sa.In each extension, the reductiou in size of the new initial set produces a change in the position of the re,naining elements; thus, for example 29 changes f,'om being the fourteenth element in S to the ninth element of S, and the seventh in Sa.As a result, the positions of consecutive multiples of any given nunber p are no longer p units apart.Instead, they can be obtained by adding cyclically the elements of a predetermined finite set of differences, depending on p, whose size varies from one extension to another.For instance, the positions of the nultiples of 7 can be obtained in S by successively adding the elements of the set {9,5}, while in S a the corresponding set of differences between the remaining multiples of 7 is {12,7,4,7,4,7,12,3}.
2. NOTATION AND BASIC DEFINITIONS.We now generalize this process for obtaining the prime numbers less than or equal to a given N. First we denote the initial set by S, that is, the set obtained from S by removing the multiples of the first k prime numbers.Then, for any p in S we determine the rules govern the positions of the multiples of p in Sk.
In any extension of the Sieve, we need to know for any given element n e Sk its position, the position of its square and of subsequent multiples of n in S k.
We start by defining a function that maps each element of Sk to its ordinal position in S k.LEMMA 2. Let Ck {c c0<c<c<"'<Cmk.1 }.The position of any element of S,is given by the injection Pos: Sk-* + defined by Pos(n) mq+i, for n q'k+ci. (2.1) PROOF.If ix e Ck, then n c for some i, and Pos (n) i.Otherwise, we can write Pos (n) kk mk +i.Hence Pos is a well defined function.
The congruence relation modulo r k partitions Sk into m k equivalent classes, where the elements of Ck are the canonical representatives, that is, Sk [.3 [cl, where [c] {x Sk Ix c(mod rk)}- cCk We will see that for any n [c] the positions of the multiples of n in Sk can be obtained by adding cyclically the elements of a predetermined finite set of differences, which in turn depend upon c.First, to determine the positions of the multiples of any element c Ck in Sk, we need he following.DEFINITION 4. Let c nd ci+ be consecutive elements of Ck.Then for ech n Sk we let Pos(nci+l)-Pos(nci), 1 5 < m k d define D {dn,i 1 5i mk }. d,,i Pos(n(Zk+l))_Pos(nCmk) mk That is, D is the set of differences of positions of the successive m k + 1 multiples of n in Sk 3. MAIN RESULTS LEMMA 5. Let c 6 Ck.The set D contains M1 possible differences of positions between consecutive multiples of c in S k, d repeats cyclically.
PROOF.Let n d nj be consecutive elements of Sk such that n k+C d ni qrk+q.Then either (a) qi and q ci+ , or (b) qj +1, c Cmk and q=l.
clas.scs are independent processes, and therefore the algorittun is particularly well suited for parallel processing.
COROLLARY 8. Let t.n Sk be such that n (rood rk).Then D, D[ + mk(qt-qn)D, where the smi is taken ow,r the i-th elements of the sets, _<i < mk.
PROOF.Since t--n (rood rk), then D[,t D[,-.Hence from the previous theorem, we obtain D, D[ (D,' + mkqtD/)-(D + mkqnDt mk(qt-qn)D. (3.6) It is well known (see [5]) that the arithmetic complexity of the Sieve of Eratosthenes is O(n log n).Even though this remains unchanged in the k-th extension, the reduction in calculations is substantial, as the next Lemma shows.100 LEMMA 9.The k-th extension of tile Sieve of Eratosthenes produces a -pTz0 reduction on the size of Su_, and a rk-::rk)% size reduction on S.
Proof.We know that (r)=(pk-1)(rk.).Moreover, in Sk each basic interval [qrk+l, (q+l)rk] contains (rk)elements, while Sk.1 has p(rk_)elements in the same interval, hence That is, the reduction in size of S k with respect to Sk_ is ---z0.
Table 1 below gives an idea of the size reduction of Sk with respect to S and Sk.respectively.Notice that the reduction on the size of Sk is accompanied with an increase on the corresponding size of (Trk), and therefore on the number of the sets of differences as well as on the size of this sets.At the same time, once we pass the fourth extension, the reduction on the size of Sk seems to be rather small while (rk) becomes too large.This suggests that even for relative large values of N, the third or the fourth extension may yield the faster results.