{'fraction_non_alphanumeric': 0.04770335398839382, 'fraction_numerical': 0.01583554637552867, 'mean_word_length': 4.111865258924082, 'pattern_counts': {'":': 2, '<': 6, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Cycles and Patterns in the Sieve of Eratosthenes

We describe recurring patterns of numbers that survive each wave of the Sieve of Eratosthenes, including symmetries, uniform subdivisions, and quantifiable, predictive cycles that characterize their distribution across the number line. We generalize these results to numbers that are relatively prime to arbitrary sets of prime numbers and derive additional insights about the distribution of integers counted by Euler's phi-function.


Introduction
In the third century B.C.E. Eratosthenes of Cyrene (276-194 BC) invented his famous sieve to identify prime numbers. Even today it remains an irresistible and practical starting point for analyzing them. Almost all mathematicians who have explored it have noticed that after each iteration there remain pairs of integers separated by 2. Some such pairs survive as twin primes; others do not, as one or both members are divided by a prime in subsequent iterations of the sieve. However, there are always an infinite number of surviving twin pairs, albeit increasingly rare. This has fueled the as yet unproven twin prime conjecture, that there are an infinite number of twin primes.
relatively prime to the first n primes. Analogously, our Sieve of Twins can be applied to M -primes.
Just as each cycle of Eratosthenes's Sieve discards integers that cannot possibly be primes, our Sieve of Twins sequentially discards endless lists of integers that cannot possibly be twin prime centers. In both cases, Eratosthenes's Sieve and our Sieve of Twins, with each succeeding "n" there are always remnants. Those remnants become thinner and thinner, but remain infinitely long, containing, respectively, potential primes and potential twin prime centers.

Our Sieve of Twins
Broadly, our Sieve of Twins mimics Eratosthenes's Sieve of Primes. However, instead of sequentially identifying primes and then discarding their multiples, it starts with a set of primes (e.g., the first n primes, or any set M of primes) and then incrementally discards all integers, x, such that either (x -1), (x + 1), or both, are divisible by one or more of the primes in the initial set. What remains is an infinite set of integers, x, that are the centers of twin integers, (x -1) and (x + 1), both of which are relatively prime to our selected set of primes.
If x takes the form (pjk -1), then x + 1 = pi·k and is therefore not a {pj}-prime. Similarly, if x takes the form (pjk + 1), then x -1 = pi·k, and it is therefore not a {pj}-prime. In either or both cases, the pair, (pjk -1), (pjk + 1), is not a pair of twin n-primes. This phenomenon is illustrated in Table 1, Centers of Twin {7} -Primes, for twins relatively prime to 7. The table also illustrates that, in accordance with Theorem 1 in Appendix 1, for a single prime, p, (in this case 7), the number of twin prime centers is cyclical, repeating every p (here, 7) integers.
The Sieve of Twins also lists the first n primes in Part 1. But Part 2 of this sieve consists of the centers of twin n-prime pairs. These centers are also symmetrically located within and are subsets of the same recurring modular rings of the n-primes. However, they do not of themselves form groups or rings. Nevertheless, they are of special interest, in that for any integer, n, the centers of all twin primes greater than n are subsets of the centers of twin n-prime pairs.
It is tempting, but misleading (and disappointing), to trust that, like Eratosthenes's Sieve, the first survivor of each cycle of the Sieve of Twins will be the center of twin primes. It almost certainly is. But we cannot prove it. It remains what we may wish to call a "potential twin prime center." On the other hand, just as Eratosthenes's Sieve produces the "next" prime, the Sieve of Twins can easily and sequentially produce a list of the "next" twin primes-or more precisely, a list of the centers of twin prime pairs. The process for doing so is as follows.
Every twin n -prime center, a, would be is the center of true twin primes, (a -1) and (a + 1), if neither of them is divisible by a prime. Since, by definition, neither one can be divided by any of the first n primes, the smallest prime that could divide either one would be the (n + 1) st prime, pn+1, and the smallest multiple of pn+1 that could do so would be (pn+1) 2 . Thus, as long as a < ((pn+1) 2 -2), then (a -1) and (a + 1) will both be smaller than (pn+1) 2 , and therefore both will be primes, and hence will be pairs of true twin primes.
This serial derivation of true twin primes from twin n -primes is illustrated in Table 8, Twin n -Primes That Are Also Twin Primes. 6 (5, 7) pn+1 = 3 (pn+1)) 2 -2 = 9 12 (11,13) 12 (11,13) 12 (11,13) 18 ( As with the Sieve of Eratosthenes, our "Twin Sieve" can be repeated for each succeeding prime. For example, for the first n primes (2, 3, 5, 7, . . . n), it is natural to apply the sieves first to 2, then 3, 5, 7, etc. However, for any given "n" we obtain the same results no matter what the order of application. For example, for the first four primes, we get the same results if we first cull out centers of twins relatively prime to, say, 5, then to 3, 7, and 2, etc., in fact, in any order.
In addition, the Twin Sieve can produce lists of twin pairs of any set, M, of primes, resulting in endlessly repeating cycles of twins that are relatively prime to the primes in M.

A Legendre-like Function for Counting Twins
A. Legendre's Formula. We will adapt Adrien-Marie Legendre's (1752 -1833) formula for counting primes in order to construct a new formula for counting twin primes, twin n -primes, and twin M -primes.
Legendre's formula for counting primes is: the sums being taken over each one, then over all the doubles, triples, etc. of the first n primes.
For any integer n and any real number x, the formula returns the number of integers ≤ x that are relatively prime to the first n primes. (It is worth noting that if x < (pn) 2 , then fn (x) -1 = the number of primes p, pn < p < (pn) 2 . Thus, incrementally increasing the value of n and adding that value to the value of Legendre's formula, it can theoretically be used to count the number of all primes of any value for x < (pn) 2 .) That is, (2) π (x) = n + fn (x) -1 for all x < (pn) 2 We may generalize this formula to integers relatively prime to all primes within a given set M of primes, i.e.
While the proof of Legendre's theorem is well known, it is worthwhile to recapitulate it here in order to set the stage for an analogous theorem for twin primes, n -primes, or M -primes that we will introduce below. The proof is based on the "inclusion-exclusion principle. While the theorem purports to be about counting n -primes, in reality it mostly counts composites involving the first n primes. Only when the numerous terms of the argument on the right side of the equation are computed and combined, and when that result is subtracted from [x], is the number of nprimes that are ≤ x revealed. If the "[x] -" part of the formula is dropped, then all the remaining terms of the formula reveal the number of integers ≤ x that are divisible by one or more of the first n primes (in the case of formula (1)) or of the primes ε M (in the case of formula (3)) Legendre's formula is impractical after just a few iterations. The tenth iteration requires more than a thousand separate calculations and the 20 th more than a million. It is a safe guess that Legendre himself never made any such calculations during his lifetime, long before today's computers were even imagined. But his formula was then, and still is today, valuable for the insights it provides about the patterns of the distribution of primes and composite integers. It allows the mind's eye to peer vast distances down the number line, not just to count primes but to better understand the patterns of their distribution.

B. Introduction to Formulas for Counting Twins.
Our formulas for counting twins are analogous to Legendre's formula. However, they are necessarily more complex because they calculate the number of pairs of integers, both of which are relatively prime to the first n primes or to the primes in set M.
As with Legendre's formula, we situate our twin-counting functions in the domain of real numbers rather than integers, because intermediate stages of most of our calculation involve real numbers rather than integers. However These functions will count the number of integers, x, that are centered between two integers, (x -1) and (x + 1), where neither of them is divisible by one of the first n primes, or by any of the primes of a given set M.

C. A Formula for Counting Twins of a Single Prime.
We begin by establishing a formula for a single prime, p. It can be derived by reflecting on our first example, p = 7, illustrated in Table 3, Centers of Twin {7} -primes.
There we see that the pattern of primes and composites is cyclical, of length 7.
For each cycle, all integers are the centers of twin {7} -primes except the first and the second last, 1 and 6. This can readily be generalized to any prime, p. Thus, our fundamental formula for calculating the number of twin n -primes or Mprimes ≤ x, for any prime p other than 2 and any real number x is: For example, the formula for counting centers of twin pairs of integers both relatively prime to 5 would be:

(9) T{5} (x) = [x] -[(x + 1) /5] -[(x + 4)) /5]
Similarly, the formula for counting centers of twin pairs of integers both relatively prime to 7 would be: We now turn to the question of how many twin prime centers are ≤ x with respect to two or more primes. To illustrate the formula, we first consider the case of two primes, 5 and 7. On the surface, we may simply apply formula 1 twice, once for each of these two primes. So as a first shot, we might guess that However, this would not be correct, because some values of T{5, 7} (x) would be implicated by both 5 and 7. This is illustrated in Furthermore, as highlighted in the table, in four cases, namely when x = 1, 6, 29, and 34, both primes 5 and 7 are implicated-i.e., those four numbers are not centers of twin M -primes for either 5 or 7. For example, 29 is not the center of twin 7 -primes, since (29 -1) = 28 is divisible by 7; and it is also not the center of twin 5 -primes, since (29 + 1) = 30 is divided by 5. Similarly, 1, 6, and 34 are bounded on one side or the other by multiples of both 5 and 7. Therefore equation (7) undercounts the value of T{5, 7} (x) for each of those four values by subtracting them twice. To correct for this undercount, we need to add back one repetition of each of the double counted values during every cycle of 35 integers. Thus, we need to substitute for equation (7) the following more elaborate formula described in Table 10.
A similar, but increasingly complex, adjustment to the formula is needed for each additional prime we introduce. For example, consider T{5, 7, 11} (x), the formula for the number of twin prime centers ≤ x whose wings, (x + 1) and (x -1) are relatively prime to 5, 7, and 11.
Like Legendre's formula, the introduction of the third prime, 11, brings new complexities. It gives rise to two new prime pairs, for a total of three such pairs, whose products are needed to compensate for the double deletion of potential twin prime centers. However, also like Legendre's formula, this compensation in turn gives rise to the need of a triplet whose product needs to be added back  in to restore twin prime centers that were deleted twice in the previous adjustment. And so on. By way of an example, the components of such a formula are identified in Table 13.
From these two examples, it is apparent that the formulas for counting twin n -primes, or twin M -primes, are even more complex than the comparable formulas for counting n -primes or M -primes. Section C. A Formula for Counting Twins of a Single Prime, hinted at this complexity by demonstrating that for a single prime, p, during each interval of consecutive p integers, two of them would be discarded as centers of twin {p} -primes, namely, [(x + 1) / p] and [(x + (p -1)) / p]. This complexity further unfolds as additional primes are taken under consideration, as reflected in Table 11.

Formula for the Number of Integers a ≤ x That Are Centers of Integer Pairs (a -1) and (a + 1), Both
Relatively Prime to 5, 7, and 11.   The last section of the table illustrates similar results for the set M = {5, 7, 11}. However, because three primes are involved rather than two, there are eight integers discarded as centers of twin M -primes with respect to those three primes. In this case, the cycle repeats itself every 385 integers, the product of 5, 7, and 11.
Let M be a finite set of primes. Define: "DM": the set of "discarded M -prime centers," i.e., integers x such that x ε PM (i.e., 0 ≤ x ≤ Πpi, pi ε M) and that each member of M divides either (x -1) or (x + 1).
Analogous definitions and notations are: "Dn": the set of discarded M -prime centers for the first n primes. We call these "discarded n -prime centers." "D{pa, pb, pc . . Examples of discarded M -prime centers are displayed in the third column of   For any integer n and any real number x, this formula returns the number of integers ≤ x that are centers of twin n-primes, with respect to the first n primes.
We may generalize this formula to integers relatively prime to all primes within a given set M of primes, i.e.
The formats of these two formulas are intended to mimic Legendre's formula for counting primes viii . We may express the same result more efficiently using function (13), DM (x), for discarded twin centers as follows:  where k = 1 if the cardinality of mi is even, and 2 if odd.
As with Legendre's formula, while formulas (15) and (16) are valid and precise, they are impractical for making manual calculations after just a few iterations. By way of comparison, ten iterations of the twin counting formula require more than 59,000 calculations; and 20 iterations require almost 3.5 billion. The 59,000 are of course still a pittance of the 100 billion integers in the natural domain of the first 10 odd primes, and again, the pattern of the distribution of those twins repeats throughout the number line within endless cyclical multiples of these first 100 billion integers.)

A. Meissel/Lehmer's Formula.
Here we will examine whether Meissel/Lehmer's formula for counting primes can be adapted to construct a new formula for counting twin primes, twin n -primes, and twin M -primes.
The principle underlying this formula is that an integer x that is relatively prime to the first n -1 primes is also relatively prime to the first n primes unless it is divisible by n th prime, pn. But that happens if and only if it also has a divisor that is ≤ x/pn.
Unfortunately, the situation is not analogous for twin n-primes. They lose their status as twins if one or both members of the pair is a composit integer, and even if a divisor of either member of the pair is any prime, not just a twin prime. Furtermore, we have cast our analysis of twin n-primes and twin M-primes in terms of their centers. Thus, our goal here is to count which, and how many, twin (n -1)-prime, or twin M-prime, centers survive as twin centers with the introduction of an additional prime. Adapting Meissel-Lehmer's prime counting formula to account for these features of twin n-primes or M-primes introduces so many complexities that the value of a single formula as elegant as Meissel-Lehmer's prime counting formula is lost.

Inductive Method for Counting Twins.
Despite the lack of a straightforward adaptation of Meissel/Lehmer's formula for counting twin primes, we may gain insights about the effects of introducing an additional prime into the mix by examining  11. The content of this table is identical to that of Table 13, but the order and grouping of the rows have been moved to focus on the changes that occur with the incremental introduction of each of the three primes, 5, 7, and 11.
The first row reveals that two calculations (-[(x+1) /5] -[(x+4) /5] ) are needed to account for the number of integers discarded as potential twin centers by the single prime, 5. However, when a second prime, e.g., 7, is introduced, six additional calculations are required--two to account for the number of integers that are discarded by 7, and then four more to compensate for double counting the combined effects of 5 and 7. The introduction of a third prime, 11, introduces even more complications, first to account for the centers discarded by 11; then to compensate for double counting by the combined effects of 5 and 11 and of 7 and 11; but then again to account for double counting the effects of those two compensations.
These modest examples reveal that things get complicated very quickly. The number of calculations needed to compute the number of twin centers ≤ x grows exponentially by a factor of 3. For example,  With such an exponential growth rate, the number of calculations needed to compute TM (x) would quickly exceed the capacity of commonly available computers. Of course, the field of mathematics has in recent years opened up to and kept pace with the development of super computers that are now widely used in counting prime numbers. However, the purpose of this paper is not to promote or facilitate such prime-counting, but rather to shed light on the theoretical underpinnings of the distributions of twin primes, n-primes, and Mprimes within the remnants of the sieve of Eratosthenes.

B. Calculating the Discarded Centers.
The central focus of our formulas for counting the number of n-primes and M-primes and in describing their distribution along the number line are the "discarded centers." For a set of primes, M, we have defined the discarded centers with respect to M as integers z such that 0 ≤ z ≤ Πpi, (pi ε M), and that each member of M divides either (z -1) or (z + 1). Thus, the pair (z -1), (z + 1) cannot be twin M-primes, since one or both members of the pair are divisible by at least one pi.

B. Calculating the Discarded Centers.
The central focus of our formulas for counting the number of n-primes and M-primes and in describing their distribution along the number line are the "discarded centers." For a set of primes, M, we have defined the discarded centers with respect to M as integers z such that 0 ≤ z ≤ Πpi, (pi ε M), and that each member of M divides either (z -1) or (z + 1). Thus, the pair (z -1), (z + 1) cannot be twin M-primes, since one or both members of the pair are divisible by at least one pi.
For example, in Tables 12 and 13, consider the subset M = {5, 11}. As both tables indicate, its "discarded centers" are 1, 21, 34, and 54. This means that they cannot be centers of twin primes because 5 and 11 divide one or both integers above or below them. For example, At this point, an open question is: how were these "discarded centers" determined? A general answer is that they were calculated using Diophantine equations of two unknowns, which typically involve integers in their formulation and solutions. A full discussion of Diophantine questions is beyond the scope of this paper. However, the following examples may give at least a taste of how such equations can be used to determine the discarded centers of twin n-primes or M-primes.
One method is to identify the twin centers associated with the set M = {5, 11} and then see which of them survive as twin centers associated with the larger set M = {5, 7, 11}.
For example, consider 34, which, as noted above, is a "discarded center" with respect to the set M = {5, 11}. This is due to the fact each member of the set M divides one of its wings. For example, 7 divides ((34 + 1) = 35) and 11 divides ((34 -1) = 33). It is also a discarded center with respect to the set M = {5, 11} within each successive multiple of 55, as indicated in  This result follows directly from Theorem 4a (in the background section) with respect to the set M consisting of those unique prime dividers of x.

Conclusion
Broadly speaking, the distributions of twin n-primes and twin M-primes follow patterns remarkably similar to that of all n-primes and M-primes, and to some extent that of twin primes themselves. Still, our vision and grasp of those infinite worlds is still murky, especially that of the twin primes, whether finite or infinite.