Вы находитесь на странице: 1из 19

1

A PRIME NUMBER SIEVE FOR RANDOM INTERVALS


by Renato de Melo E-mail: renatodemelo1958@gmail.com Santos SP, Brazil December 1st 2012.

FOREWORD Before all, I must state that I have never attended a college course, or whatsoever, regarding the exact sciences, not to mention Mathematics. My knowledge is limited to what I learned at formal elementary and high school courses and to what my own curiosity on the subject allowed me to acquire. Hence, as a nearly dummy at Mathematics, I must apologize for the awkwardness of certain formulations or definitions presented in this article. In fact, I tried my best to meet the standard language and expressions in the field, but I am not sure I have succeeded on the whole, that is why some of the definitions and demonstrations may seem too short, stupid, clumsy, or even obvious, due to the fact that most of the time I really did not know whether what I had stated was something new or already established in Mathematics. Moreover, there are a lot of apparently minor details developed and presented herein just for the benefit of the doubt, because my lacking specific knowledge made me sometimes regard some of the findings as useless and later on they turned out to be somewhat important. Yet, in the end, I guess I have achieved a certain degree of clarity and precision concerning the most important concepts, formulations and definitions of the topic in this article. Thus, I can assure that my demonstrations and conclusions can be easily understood by whoever has minimum acquaintance with the subject. P.S.: Sorry for the various dangling participles but sometimes they are the simplest way to communicate something, so I used them with discretion, though.

2 1 1.1 INTRODUCTION A FEW PRELIMINARY DEFINITIONS Throughout this article, except where otherwise stated, the following terms and expressions are defined as: a) literal constants or variables, such as a, b, d, k, m, n, q, r, x, y etc, are previously defined for the set of the whole numbers, N0 = { 0, 1, 2, 3, }; as do the expressions whole number, or number; b) factorization of or factoring composite numbers refer to the process of factoring a number into two factors only, either prime or composite, other than one and the number itself. Also, the factor or factors of a number respectively refer to one or both of those factors, either prime or composite, other than one and the number itself, resulting from factorizing such a number into two factors only. As prime numbers have only two factors, namely: one and that prime number itself, and composite numbers have a minimum of four factors, namely: one, the composite number itself and two other factors (e.g.: the factors of number 6 are 1, 6, 2 and 3, four in all), the choice to work with only two factors, two addends or only one minuend and one subtrahend, was the best solution to cope with the enormous number of combinations of factors for those composite numbers in an attempt to simplify the system and, thus, know, understand and extract some properties and particularities of that system, that might otherwise remain hidden; c) the expression square(s) of a given whole number means the perfect square(s) of such a number; and d) the expression multiple(s) of 2x only means any even number that, when factored into two distinct factors, presents an even factor 2m, and an odd factor 2k + 1. For instance, a multiple of four only means a number that is a multiple of four, but not a multiple of eight, so it is a number of the form 4 (2k + 1), four times an odd number. 1.2 A FEW PRELIMINARY CONSIDERATIONS With those preliminary definitions, let n 1 and n + 1, respectively, be the predecessor and successor of n; so, in ascending order, their respective squares are: (n 1) = n 2n + 1; n; and (n + 1) = n + 2n + 1.

3 As n > n 1 and n > (n 1), consequently, n (n 1) = 2n 1. Therefore, if we consider any number k lying within an open interval bounded by those two consecutive squares, where (n 1) < k < n, the quantity of numbers between them is: (2n 1) 1 = 2n 2 = 2 (n 1). As n + 1 > n and (n + 1) > n, consequently, (n + 1) n = 2n + 1. Therefore, if we consider any number k lying within an open interval bounded by those two consecutive squares, where n < k < (n + 1), the quantity of numbers between them is: (2n + 1) 1 = 2n. As n + 1 > n 1 and (n + 1) > (n 1), consequently, (n + 1) (n 1) = 4n. Therefore, if we consider any number k lying within an open interval bounded by the squares of n 1 and n + 1, i.e., (n 1) < k < (n + 1), the quantity of numbers between those squares is 4n 1. Such results may be interpreted as follows: a) the difference between any two consecutive squares (of any two consecutive numbers) is an odd value; b) the quantity of numbers in the open intervals between any two consecutive squares (of any two consecutive numbers) is twice the smaller value bounding the interval; therefore, even; c) the difference between the squares of n 1 and n + 1 (the difference between any two squares of any two consecutive odd/even numbers) is the quadruple of n, which is the number lying between them; therefore, even and a multiple of 4, and, in the case n is even, also a multiple of 8; d) in the open interval between the squares of n 1 and n there are only two multiples of n 1. The first multiple of n 1 is: (I) (II) (n 1) + (n 1) = (n 1) (n 1 + 1) = n (n 1) = n n. Its second multiple is: (n 1) + 2 (n 1) = (n 1) (n 1 + 2) = (n 1) (n + 1) = n 1; e) in the open interval between the squares of n and n + 1, there are only two multiples of n.

4 The first multiple of n is: (III) (IV) n + n = n (n + 1). Its second multiple is: n + 2n = n (n + 2); f) in the closed interval bounded by the squares of n 1 and n + 1 there are four multiples of n as the difference between their squares is 4n; and the same holds true when we consider the open interval between their squares, which has the length of 4n 1 numbers in between. In ascending order, they are: n (n 1) [ (I), which is even; the difference between the factors is one ]; n [ the square of n itself; the difference between the factors is zero ]; n (n + 1) [ (III), also even; the difference between the factors is one ]; and n (n + 2) [ (IV), the difference between the factors is two ]; g) there are four multiples of n 1 in the open interval between the squares of n 1 and n + 1. In ascending order, they are: (n 1) + (n 1) = (n 2n + 1) + (n 1) = n 2n + 1 + n 1 = = n n = n (n 1) [ (I) ]; (n n) + (n 1) = n n + n 1 = n 1 = (n 1) (n + 1) [ (II) ]; (V) (n 1) + (n 1) = n 1 + n 1 = n + n 2 = [ n (n + 1) ] 2 = (n 1) (n + 2) [ this multiple lies in the open interval between the squares if n > 1; and, as the difference between the factors is three, it is even ]; and (n + n 2) + (n 1) = n + 2n 3 = [ n (n + 2) ] 3 = (n 1) (n + 3) [ the difference between the factors is four, thus either even or odd ]; h) in the closed interval bounded by the squares of n 1 and n + 1 there are four multiples of n + 1 as the difference between the squares is 4n; and there are three multiples of n + 1 when we consider the open interval between their squares, which has the length of 4n 1 numbers in between. In descending order, they are: (n + 1) [ the square of n + 1 itself, but it lies out of the open interval; the difference between the factors is zero ]; n (n + 1) [ (III) ]; (n 1) (n + 1) [ (II) ]; (VII) (n 1) (n + 1) = n 1 n 1 = n n 2 = [ n (n 1) ] 2 = (n 2) (n + 1) [ this multiple lies in the open interval between the squares if n > 3; if n = 3, it is 4, the square of n 1; as the difference between the factors is three, it is even ]; and

(VI)

5 (VIII) (n n 2) (n + 1) = n 2n 3 = [ n (n 2) ] 3 = (n 3) (n + 1) [ this multiple always lies outside the open interval between the squares; precisely, before the predecessor of (n 1) as indicated by n (n 2) ]. The analysis of all those multiples(VIII) inclusive, not lying within the interval, whether open or closed, between the squares of n 1 and n + 1makes possible the creation of a prime number sieve applied to random intervals, and the next topics and subtopics present the basic elements for that task. 1.3 (II) (IV) DIFFERENCES OF TWO SQUARES When we compare (II) to (IV), (n 1) (n + 1) = n 1; and n + 2n = n (n + 2); a) in both expressions, the difference between the larger factor and the smaller factor is two; b) the factors in both expressions are the predecessor and the successor of the number being squared next; and c) the product obtained by multiplying the predecessor by the successor of a whole number is the predecessor of the square of such a number. That is the meaning of n 1 for all squares of whole numbers. 1.3.1 A DIFFERENCE OF TWO SQUARES (n 1) AND DIGITAL ROOTS1 Two curious aspects can be noticed by relating n 1 (a difference of two squares) with the digital roots of its successor: a) as the digital roots of all squares of multiples of 3, 3 inclusive, either even or odd, are 9 [ dr(3n) = 9 ] and the difference of two squares n 1 is the predecessor of such squares, the digital root of the latter is 8 [ dr(n 1) = 8 ]; and
1

the conclusions are:

For the purposes of this article the concept and definition of Digital Root are taken from the page on Digital Root of the site Wikipedia: The Free Encyclopedia. The digital root [] of a number is the (single digit) value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-digit number is reached. For example, the digital root of 65,536 is 7, because 6 + 5 + 5 + 3 + 6 = 25 and 2 + 5 = 7. [ 1 ] It is important to note that the Digital Root of a number should not be mistaken for the Digit Sum of a number. The difference between those two concepts is quite clearly examined on their respective pages from the Wikipedia: The Free Encyclopedia. [ 2 ]

6 b) as the digital roots of all other squares, not multiples of 3, either even or odd, are 1, 4 or 7 [ dr(3n 1 or 3n 2) = 1, 4 or 7 ] and the difference of two squares n 1 is the predecessor of such squares, the digital root of those predecessors is 9, 3 or 6, respectively, [ dr(n 1) = 9, 3 or 6 ]; and, in that case, n 1 is a multiple of 3. 1.4 OPEN INTERVALS BETWEEN CONSECUTIVE SQUARES SPLIT INTO TWO HALVES As seen in the introduction of subtopic 1.3, the second multiple of n 1, or n, (II) or (IV), within the respective open intervals between their squares and the squares of their successors, is the predecessor of the squares of their successors. Hence, they are the last number of the open interval between the squares of n 1, or n, and the squares of their successors. As the difference between the mentioned squares minus 1, as seen in subtopic 1.1, is always even, it means that such intervals can be split into two exact halves, and that the last number of the second half is the second multiple of n 1, or n, analyzed before, i.e., (II) or (IV). When we compare (I) and (III) in subtopic 1.1, (I) (III) n (n 1) = n n; and n + n = n (n + 1); a) in both expressions, the difference between the larger factor and the smaller factor is 1; b) the factors in expression (I) are n and its predecessor; and in expression (III) are n and its successor; c) the product from the multiplication of n and, respectively, its predecessor, or successor, is an even number: either for the fact that the difference between the factors is 1 and, as a result, one of the factors is always even, or that both n n and n + n are, respectively, the subtraction and the addition of two odd numbers or two even numbers, what would always result in an even number; d) the product of n and its successor or predecessor, n (n + 1) or n (n 1), is the last number of the first half of the open intervals, whose lenghts are of 2n or 2 (n 1), respectively, between the squares of any two consecutive numbers, because the difference for both intervals (between the squares of n + 1 and n, or n and n 1) minus 1 is the double of the smaller factor: 2n or 2 (n 1), respectively; and

the conclusions are:

7 e) as a consequence, the successor of n (n + 1), or n (n 1), is always odd, for: n (n + 1) + 1 = n + n + 1 (n + n is even; its successor is odd); n (n 1) + 1 = n n + 1 (n n is even; its successor is odd). Also, n (n + 1) + 1 or n (n 1) + 1 are the first numbers of the second half of the intervals, whose lengths are of 2n or 2 (n 1), respectively, between the squares of any two consecutive numbers. From that, the open interval between two consecutive squares, n and n + 1, can be split into two halves: a) the first half starts at n + 1 and ends at n (n + 1); and b) the second half starts at n (n + 1) + 1, or n + n + 1, and ends at (n + 1) (n 1). The length of both halves is exactly n. An interesting feature of n (n + 1), or n (n 1), is that both are the double of triangular numbers. 2 SEQUENCES OF DIFFERENCES OF TWO SQUARES As n means the product of n times n, then the difference between its factors is zero; and the difference between the factors of its predecessor is two, wherein the smaller factor is n minus 1 (n 1), and the larger factor, n plus 1 (n + 1). The subtraction of 1 from the smaller factor and the addition of 1 to the larger factor of the predecessor of n, i.e., n 1, result in: (n 1 1) (n + 1 + 1) = (n 2) (n + 2) = n 4. Again, from the last expression (n 4), the subtraction of 1 from the smaller factor, now n 2, and the addition of 1 to the larger factor, now n + 2, result in: (n 2 1) (n + 2 + 1) = (n 3) (n + 3) = n 9. Therefore, the continuous subtraction of 1 from the smaller factor and the addition of 1 to the larger factor of the last resulting expression always result in a difference of two squares, n d, where the first term n is the number itself, and the second, d is equal to the number of times the value 1 is subtracted from, or added to, n; consequently, d is the difference between n and the smaller, or larger factor, of that particular element in a sequence of differences of two squares. That means that d is the difference between both factors divided by two. For example, let n = 5, then the antepenultimate, or the third,

8 element of the sequence is (n 3) [ = 2, the smaller factor ] times (n + 3) [ = 8, the larger factor ] equals 16. The operation of repeatedly subtracting 1 from the smaller factor and adding 1 to the other necessarily leads to the last resulting smaller factor, which is 1. Because the starting smaller factor is n, from n, the difference between the first and the last resulting smaller factor is d = n 1; and so is the difference between n, as the first larger factor, and the last resulting larger factor: d = n + (n 1) = 2n 1. Such an operation creates a sequence that begins at the element 1 time (2n 1), any odd number, and ends at n times n, or n. Hence, 1 time (2n 1) = n d, where d = n 1: n d = n (n 1) = n n + 2n 1 = 2n 1. Whether the sequence begins at n times n (in descending order of the elements) or at 1 time (2n 1) (in ascending order of the elements, but then, with the addition of 1 to the smaller factor and the subtraction of 1 from the larger factor and the end at n times n), the sum of both factors along the whole sequence is 2n, from beginning to end. The consequence of such an operation is that from any odd number, considered as the larger factor when multiplying 1 to such an odd number [ 1 time (2n 1) ], it is possible to determine the square of the number that is the last element of the sequence by simply adding the factors of any element of the sequence and dividing the result by 2. For instance, from 3279, considered as 1 time 3279, there is a sequence of differences of two squares that ends at the square of 1640 (3279 + 1 = 3280; 3280 / 2 = 1640). The subtraction of 1 from 1640 results in 1639 (d), which subtracted from 3279 equals 1640; therefore, the last composite element in the sequence is the square of 1640. If we consider, for instance, the product 3 times 3277 (the third element of the sequence starting at 1 time 3279), the same calculation gives the same result: 3277 + 3 = 3280; 3280 / 2 = 1640. As the difference between the factors of the composite numbers of the sequence resulting from the aforementioned operation is always even, if we begin, or end, the sequence at the square of an odd number, n 1 is even, n 4 is odd, n 9 is even again, and so on. On the other hand, if we begin, or end, the sequence at the square of an even number, then n 1 is odd, n 4 is even, n 9 is odd again, and so on. Since two consecutive elements of the sequence are alternately odd and even, the difference between them is always odd and equal to the difference between the second term (d) of each

9 element in the sequence of differences of two squares. Therefore, that difference is always the difference between (d'') and (d'), where d'' = d' + 1. In terms of the factors of those elements, the difference between two consecutive elements, n (d'') and n (d'),where d'' = d' + 1, is always the difference between the factors of n (d'), (n d') and (n + d'), plus 1, or also the difference between the factors of n (d''), (n d'') and (n + d''), minus 1. As [ n (d'') ] < [ n (d') ], then: [ n (d') ] [ n (d'') ] = n (d') n + (d'') = (d'') (d'). By substituting d'' for d' + 1 in (d'') (d') equals (d' + 1) (d'), then: (d' + 1) (d') = (d') + 2 d' + 1 (d') = 2d' + 1 (odd) [ the difference between the factors of n (d') plus 1 ]. On the other hand, when substituting d' for d'' 1 in (d'') (d'), then: (d'') (d'' 1) = (d'') [ (d'') 2 d'' + 1 ] = (d'') (d'') + 2 d'' 1 = 2d'' 1 [ odd again, and the difference between the factors of n (d'') minus 1.]. When we examine at (VI) and (VIII), whether starting the sequence at the square of n or at 1 time (2n 1), both multiples are, respectively, the third or the antepenultimate element of their respective intervals; so their analysis falls into the analysis of the whole sequence itself. Furthermore, as regards the quantity of elements of the sequence: a) the number of elements of the sequence is n because the smaller factor varies from n to 1, or vice versa; and b) about half the elements of the sequence are even; while the others are odd. 2.1 SEQUENCES OF DIFFERENCES OF TWO SQUARES AND DIGITAL ROOTS The last subject in subtopic 1.3.1, on the digital roots of the elements of the sequence of differences of two squares, shows a special characteristic of the sequence, namely, the set of squares can be split into two groups: the first group comprises those squares with dr(3n) = 9, multiples of 3; and the second group comprises all other squares, with dr(3n 1 or 3n 2) = 1, 4 or 7. In the sequence starting, or ending, at the first group, every third element along the sequence is a multiple of 3; but all the others are not; whereas the sequence starting, or ending, at the second group every third element along the sequence is not a multiple of 3, but all the others are. In fact, by factoring those composite numbers in the sequence into the product (n d) (n + d), if n is a multiple of 3 (starting/ending a sequence of the first

10 group), then the product [ n (d + 3k) ] [ n + (d + 3k) ] is definitely a multiple of 3; hence, by continually increasing the difference by 3, every third element is also a multiple of 3. From the analysis of the second group, clearly, n 1 is a multiple of 3 because its digital roots are 3, 6 or 9; but every third element of the sequence cannot be a multiple of 3 because n is not a multiple of 3; hence, when subtracting 9d, a square of a multiple of 3, from n, the result is definitely not a multiple of 3. However, all the other elements of the sequence are multiples of 3. If we consider any element of the sequence whose d is not a multiple of 3, since n is not a multiple of 3, when subtracting d from n, the result has to be a multiple of 3 if d is a number of the form 3k 1 or 3k 2. Thus, those elements are of the form: n d = (n d) (n + d) = [ n (3k 1) ] [ n + (3k 1) ] = n (3k 1); n d = (n d) (n + d) = [ n (3k 2) ] [ n + (3k 2) ] = n (3k 2). The development of the first expression results in: n (3k 1) = (n 1) (9k 6k) = (n 1) 3 (3k 2k). As in this case n is not a multiple of 3, n 1 is a multiple of 3, and the second term is a multiple of 3, the result has to be a multiple of 3. The development of the second expression results in: n (3k 2) = (n 1) (9k 12k + 3) = (n 1) 3 (3k 4k + 1). As in this case n is not a multiple of 3, n 1 is a multiple of 3, and the second term is a multiple of 3, the result has to be a multiple of 3, as well. Consequently, if a sequence belongs to the first group, then it is possible to state that one third of its elements are multiples of 3; on the other hand, if it belongs to the second group, about two thirds of its elements are multiples of 3. 2.2 TWO FUNCTIONS OF SEQUENCES OF DIFFERENCES OF TWO SQUARES For logical, but not always practical, matters, from now on, the beginning of the sequence will be fixed at 1 time (2n 1). Table 1 below shows the sequences of differences of two squares resulting from odd numbers from 1 to 13 by using the operation described before. Clearly, the moment the sequences reach a square, there is no need to continue the operation because the

2.2.1 FIRST FUNCTION: f(x) = 2nx x

11 combination of factors repeats itself by repeating the smaller and larger factors but at inverted positions. Table 1. Sequences of Differences of Two Squares Beginning at 1 time (2n 1)
1
1x1 2x0

3
1x3 2x2 3x1 4x0

5
1x5 2x4 3x3 4x2 5x1 6x0

7
1x7 2x6 3x5 4x4 5x3 6x2 7x1 8x0

9
1x9 2x8 3x7 4x6 5x5 6x4 7x3 8x2 9x1 10 x 0

11
1 x 11 2 x 10 3x9 4x8 5x7 6x6 7x5 8x4 9x3 10 x 2 11 x 1 12 x 0

13
1 x 13 2 x 12 3 x 11 4 x 10 5x9 6x8 7x7 8x6 9x5 10 x 4 11 x 3 12 x 2 13 x 1 14 x 0

As all odd numbers are the starting element of a sequence of differences of two squares and can be denoted as the expression 2n 1 (the larger factor of the first element of the sequence), by subtracting 1 (decremental factor) from that factor, the absolute value of the resulting term that subtracts 2n is always equal to the smaller factor itself: (2n 2) x 2; (2n 3) x 3; (2n 4) x 4 etc. Hence, it is possible to set one of the functions of sequences of differences of two squares: f(x) = x (2n x) = 2nx x , a simple quadratic function, where n is taken as a constant valuenot as a variable in the functionand x is any whole number, since, if x = 0 then f(x) = 0, the square of zero, for any value of n. Table 2. First Function of Sequences of Differences of Two Squares: f(x) = 2nx x for n = 7
2n 1 = 13
1 x 13 2 x 12 3 x 11 4 x 10 5x9 6x8 7x7

x
1 2 3 4 5 6 7

2n x
2n 1 2n 2 2n 3 2n 4 2n 5 2n 6 2n 7

14 x
= 14 1 = 14 2 = 14 3 = 14 4 = 14 5 = 14 6 = 14 7

Larger Factor
= 13 = 12 = 11 = 10 =9 =8 =7 (14 x 1) 1 (14 x 2) 4 (14 x 3) 9 (14 x 4) 16 (14 x 5) 25 (14 x 6) 36 (14 x 7) 49

14 x ( 2nx x )
= 14 1 = 28 4 = 42 9 = 56 16 = 70 25 = 84 36 = 91 49 = 13 = 24 = 33 = 40 = 45 = 48 = 49

12 Table 2 above shows all significant values of x for n = 7 in that function, which is neither even nor odd: EVEN [ f(x) = f(x) ]: f(x) = 2nx x = x (2n x) [ FALSE: x (2n x) < x (2n x) ]. ODD [ f(x) = f(x) ]: f(x) = 2nx + x = x (2n + x) [ FALSE: x (2n + x) > x (2n x) ]. 2.2.2 SECOND FUNCTION: f(x) = n x The second function of sequences of differences of two squares is a mere adaptation of the expression n d analyzed before and is defined as f(x) = n x, another simple quadratic function, where n is also taken as a constant valuenot as a variable in the functionand x is any whole number, since, if x = 0 then f(x) = n, the square of n, for any value of n. Such a function is even: EVEN [ f(x) = f(x) ]: f(x) = n x [ TRUE ]. ODD [ f(x) = f(x) ]: f(x) = n + x [ FALSE ]. Notice that it is only true for x = n, because: a) if n > x, then n + x < n x [ FALSE ]; b) if n = x, then n + x = n x [ TRUE ]; and c) if n < x, then n + x > n x [ FALSE ]. Table 3 below shows all the significant values of x, for n = 7, in the function. Table 3. Second Function of Sequences of Differences of Two Squares: f(x) = n x for n = 7
x
0 1 2 3 4 5 6 7

nx
7 6 5 4 3 2 1 0

n+x
7 8 9 10 11 12 13 14

n x
= 49 = 48 = 45 = 40 = 33 = 24 = 13 =0

Another important aspect, when we relate both functions, is that, if their Domain set is defined as 0 x n, they share the same Image set, but the order of their elements is

13 inverted: while the Image of the first function increases, the Image of the second one decreases. 3 THE PRIME NUMBER SIEVE FOR RANDOM INTERVALS The basic principle ruling the prime number sieve for random intervals lies in the fact that all odd numbers belong to at least one (in the case of prime numbers) sequence of differences of two squares; and, in the case they belong to two or more, they are obviously composite. Also, completing what was seen in the introduction of topic 2, even numbers may belong either to a sequence of differences of two squares, or to a sequence starting at an even number, that is, by applying the same process described in topic 2, we can build a sequence of even numbers that ends at n (n + 1), because the difference between the factors of the first element of the sequence, starting it at 1 time 2k, is odd. Therefore, after continuously adding one to the smaller factor (one), and subtracting one from the larger factor (2k), the difference between both factors is still odd, thus, all elements of such a sequence are always even and eventually the difference between both factors will decrease to one in the case of the last element of the sequence, n (n + 1). Because of that, all singly even numbers belong to one of those sequences starting at an even number, never to a sequence of differences of two squares: the second element of the latter is always even, but a doubly even number, as the first element is always odd. We can easily conclude that only doubly even numbers belong to a sequence of differences of two squares. Now, as to prime numbers, even numbers are not a problem mainly because even numbers greater than two are composite. In theory, just from the above-mentioned basic principle, it is possible to detect all composite odd numbers in any randomly-selected closed interval, no matter the bounds, because, after calculating all sequences of differences of two squares that go through that specific interval, we are able to eliminate all composite odd numbers within such an interval. Yet, the calculation of such is far more complicated. The easiest way for such a sieve is to consider open intervals between two squares, either consecutive or not. Table 4 below shows an example of the sieve applied to a specific interval between two consecutive squares (the easiest way of applying the sieve to an interval). For practical matters, I have omitted all even numbers in the interval, except for the even square itself,

14 and consequently all even elements of the sequences of differences of two squares that go through that interval. Due to that, the operation described before needs a small adjustment: instead of adding or subtracting one, we add or subtract two to/from the factors of each element; thus, skipping all even elements of the sequences, as long as the last element of the sequence, n, is odd because, in the case n, and consequently the last element, is even,
calculations must start at n 1, the last odd element of the sequence, as, for example in Table 4, the squares of 12, 14, 16 etc.

Table 4. The Sieve Applied to the Open Interval between the Squares of 11 and 12 123 125 127 129 131 133
7 x 19 5 x 25 5 x 27

135 137 139 141


9 x 15

143

144
13 x 13 14 x 14 15 x 15 16 x 16 17 x 17 18 x 18 19 x 19 20 x 20 21 x 21 22 x 22 23 x 23 24 x 24 25 x 25

11 x 13 12 x 12

3 x 41 3 x 43 3 x 45 3 x 47

Although, in theory again, those calculations might start at either the first or last element of each sequence, it is much easier for mere humans that the operation starts at the last element of each sequence: the square itself. Basically, when calculating the upper bound of those sequences, as singly even numbers do not belong to a sequence of differences of two squares, the last element, i.e., square of the last sequence that goes through the specified interval, can be calculated from the largest doubly even number of the interval. For example, the largest doubly even number between the squares of 11 (121) and 12 (144) is 140 (2 times 70), so the last sequence of differences of two squares is the one starting at 1 time 71 and ending at 1296, the square of 36. Yet, as we can see from Table 4 above, it is not wise to calculate the last sequence from the largest doubly even number because if we consider it a multiple of 2, the previous element of that sequence is its first element, an odd number, therefore either prime or composite; on the other hand, if we consider it a multiple of 4, and if it is not a multiple of four only, then also a multiple of eight, we would be skipping the odd multiples of three

15 that surely belong to a sequence of differences of two squares. Then, the best way is to calculate that last sequence directly from the largest odd multiple of three. In our example, that number is 141, or 3 times 47, then the first element of the last sequence is 1 time 49 and the last element is 25 times 25. And that is enough. As to the lower bound, it is obviously the larger square bounding that same interval: in the example shown above, it is the square of 12. No other square smaller than that is the last element of a sequence that goes through the sample interval. 3.1 CALCULATING THE LOWER AND UPPER BOUNDS In the introduction above, I presented the simplest way of building the sieve for an open interval between any two consecutive squares by determining the first and last sequences, i.e., the last elements of the sequences of differences of two squares, that go through the given interval with which we can operate to eliminate all composite odd numbers in that given interval. Also, I called the lowest and highest sequences that go through a given interval as the lower and upper bounds respectively and used their last element as the bounds themselves. However, that terminology is not quite accurate. In reality, the bounds of each sequence of differences of two squares are its smallest and largest elements that fall into the given interval. Now, in order to refine those calculations, the first step is to understand how to calculate the lower and upper bounds, or, in other words, the smallest and largest elements, of each sequence of differences of two squares that fall into that specific interval. As seen in the introduction of topic 2, starting a sequence of differences of two squares at the last element, the square itself, the distance between two consecutive elements increases as an arithmetic progression with a common difference of two and the first element of that progression is one: the difference between the first two elements of the sequence, i.e., n and n 1. Therefore, some of the elements of a sequence will be greater or smaller than the bounds of the open interval under scan. Thus, to determine the smallest and the largest elements of each sequence falling into that given interval, we have to calculate the length of all open intervals for each one of those sequences by setting the first square of the studied interval (its lower bound) as the lower bound of all of them, and the square of each sequence (its last element) as the upper bound. Only after that, we can

16 calculate the smallest and largest elements of each sequence falling into the open interval under scan. Then, for the next proofs, let n, c, d and s be any numbers, so n + c + d > n + c > n. 3.1.1 CALCULATING THE LENGTH OF THE OPEN INTERVAL FOR EACH SEQUENCE The closed interval between n and (n + c) has 2nc + c elements; and the open interval between those two squares has 2nc + c 1 elements, as follows: (n + c) n = n + 2nc + c n = 2nc + c. As a consequence, if c is odd, then the length of the closed interval is odd; if c is even then its length is even. Surely, that might also be inferred from the fact that if c is even then n and n + c are both odd or even, thus the difference between them is always even. On the other hand, if c is odd, then the length of the open interval is even; if c is even then its length is odd. 3.1.2 CALCULATING THE LOWER BOUND FOR EACH SEQUENCE As we are dealing with sequences of differences of two squares, all the elements of those sequences are of the form n s, where n is the number squared at the last element of each sequence, and, as seen in topic 2, s is the square of the difference between both factors (of one particular element) divided by two. When we operate with a restricted interval, it is clear that there is a limit for the values of s: it cannot be greater than the length of each interval because it would result in an element smaller than the lower bound of the interval. Consequently, because the smallest element of a sequence going through the studied interval is (n + c) [ (int) an element is 2 x [ (int)

2nc+c ], the maximum difference between the factors of

2nc+c ] (twice the integer part of the square root of the length

of each interval, as calculated in subtopic 3.1.1 above). From that we can conclude that the smaller and larger factors of the smallest element (within the interval) of each sequence going through our open interval between two consecutive squares are: Smaller Factor = (n + c) [ (int)

2nc+c ]; and Larger Factor = (n + c) + [ (int) 2nc+c ].


Table 5 below shows the calculations for all lower bounds in Table 4. All even smallest elements are highlighted in light gray.

17 Table 5. Applied Calculations for the Lower Bounds of All Sequences in Table 4 (n = 11)
n + c 12 13 14 15 16 17 18 19 20 21 22 23 24 25 c
1 2 3 4 5 6 7 8 9 10 11 12 13 14

2nc + c 23 48 75 104 135 168 203 240 279 320 363 408 455 504

Smaller Larger 2nc+c Factor Factor


4 6 8 10 11 12 14 15 16 17 19 20 21 22 8 7 6 5 5 5 4 4 4 4 3 3 3 3 16 19 22 25 27 29 32 34 36 38 41 43 45 47 128 133 132 125 135 145 128 136 144 152 123 129 135 141

(int)

Previous Previous Smaller Larger Factor Factor 7 17 6 20 5 23 4 26 4 28 4 23 3 33 3 35 3 37 3 39 2 42 2 44 2 46 2 48

119 120 115 104 112 92 99 105 111 117 84 88 92 96

Next Next Smaller Larger Factor Factor 9 15 8 18 7 21 6 24 6 26 6 21 5 31 5 33 5 35 5 37 4 40 4 42 4 44 4 46

135 144 147 144 156 126 155 165 175 185 160 168 176 184

As we can see from Table 5, if the lower bound, or smallest element of the sequence is even, it is no trouble because the element previous to this is smaller than the lower bound of our interval, i.e., n, so there is nothing else to do. 3.1.3 CALCULATING THE UPPER BOUND FOR EACH SEQUENCE To calculate the upper bound of the sequences that go through the studied interval, or its largest element falling into the interval, an approach similar to calculating the lower bound is necessary but it presents some differences. Firstly, we have to calculate the lower bounds of all sequences going through the interval between (n + c) and (n + c + d) thus establishing the largest elements falling after the interval, or greater than (n + c), and these are exactly the smallest elements within the interval between (n + c) and (n + c + d). That is why calculations are similar to finding the lower bounds of all sequences, except that now the intervals start at (n + c), and their lengths are: (n + c) = n + 2nc + c; (n + c + d) = n + c + d + 2nc + 2nd + 2cd; and (n + c + d) (n + c) = 2nd + 2cd + d. Consequently, the smallest elements in that interval are: (n + c + d) [ (int)

2nd+2cd+d ], as seen above.

18 The factors of those smallest elements are: Smaller Factor = (n + c + d) [ (int)

2nd+2cd+d ]; and Larger Factor = (n + c + d) + [ (int) 2nd+2cd+d ].


Necessarily, then, the element previous to the smallest element (smaller than that one) falls into the interval between n and (n + c) and is the upper bound, the largest elements, of all sequences going through this interval. In that case, all we have to do is to add one to the second term of element, i.e., n (s + 1) . Then the upper bound is: Upper Bound = (n + c + d) [ (int) The factors of the upper bound are: Smaller Factor = (n + c + d) [ (int)

2nd+2cd+d + 1 ].

2nd+2cd+d + 1 ]; and Larger Factor = (n + c + d) + [ (int) 2nd+2cd+d + 1 ].


Now again, it does not matter if the lower bound is odd or even, because surely the previous element falls into the scanned interval and if it is even, we know it is composite. Yet, for practical matters, if this lower bound is odd, we had better add two to the square root of the second term, just to save some time. 3.2 CALCULATING THE LOWER AND UPPER BOUNDS FOR PROGRAMMING PURPOSES To build an algorithm for this sieve, I would strongly suggest that, after calculating those bounds (including the limits of the number of sequences that go through the interval: the last being the one calculated from the largest odd multiple of three, and the first, the one ending in the square of n + c), programmers should develop a simple loop with which they can check each odd number within the scanned interval, one by one, against each one of the sequences of differences of two squares going through that interval; but this time, we had better start checking at the lowest element of each sequence up to the largest element. Just invert what was explained above for memory saving reasons (and in the case of very high numbers).

19

REFERENCES [ 1 ] Digital root. 1 March 2011 at 00:58 UTC. In Wikipedia: The Free Encyclopedia. Wikimedia Foundation Inc. Encyclopedia on-line. Available from: http://en.wikipedia.org/wiki/Digital_root. Retrieved on 1 March 2011. [ 2 ] Digit sum. 7 March 2012 at 00:47 UTC. In Wikipedia: The Free Encyclopedia. Wikimedia Foundation Inc. Encyclopedia on-line. Available from: http://en.wikipedia.org/wiki/Digit_sum. Retrieved on 25 March 2012.

Вам также может понравиться