24 February 2006

A Practical Prime Number Producing Formula Presented in Algorithmic Form

Robert A. Warren 

The prime number formula presented here is the best of my simple formulas. This formula uses small primes to produce larger, guaranteed-to-be-prime numbers (positive integers only) of less than about 1,000. The formula produces only prime numbers as output (N values) in the range of magnitude greater than 1 but less than K. I refer to this as “the range of guaranteed primality.” The formula is based on my original prime number theorem, which may be stated as,

Given two natural numbers, N and K, where K > N and N > 1, if N has no prime factor < sqrt( K), then N is prime.

I have more advanced formulas that make the generation of large primes easier, but they are not included here, partly because the formulas require the presentation of much more theory 

As for the simpler formula that is described here, a proof of this easy-to-prove theorem on which it is based is included at the end of this paper. Below each numerical example is an informal proof of the primality of the N value produced by my formula in that example. If the informal proof is read first, the significance of my theorem should be more easily seen.                                                                                                                                     

In the numerical examples, (Pg+1)2 = K.

Pg is the largest prime factor < sqrt ( K). We remember that Pg+1 = sqrt ( K).

Prime Number Formula: Steps of the Algorithm

1. List a series of consecutive small prime numbers, starting with the smallest prime in the number system (2).

2. Label the primes. Label the largest prime Pg+1, and label the next largest prime Pg. Label the smallest prime P1, the next consecutive prime P2, etc., up to Pg.

3. Divide the primes P1 through Pg into two groupings. The primes may be divided up in any way, with any number of primes in each grouping. No prime may be put in both groupings. A grouping may consist of as few as one prime.

4. Multiply the primes in each grouping together to form a product of all the primes in that grouping. We will call these product A and product B. Any prime in each product may be raised to any integral power greater than 1.

5. Find (Pg+1)2, which is the upper limit of the range of guaranteed primality.

6. Find N, which is the absolute value of the difference of product A and product B. It can easily be proven that the difference of A and B cannot contain as a factor, any prime factor of either A or B. If N is greater than 1 but less than (Pg+1)2, then N is guaranteed by the theorem to be prime.

If N is greater than (Pg+1)2, then N is not guaranteed to be prime, but is likely to be prime nonetheless. In other words, the output of this formula is prime rich for values of N greater than (Pg+1)2.

My theorem also guarantees A+ B to be prime if it is smaller than (Pg+1)2, but A + B is seldom small enough to be so guaranteed. It can easily be proven that the sum of A and B cannot contain as a factor any prime in either A or B.

Numerical Example #1 of the Use of the Prime Number Producing Formula.

Step One:

List a series of consecutive small prime numbers, starting with the smallest prime in the number system (2).

Our series is: 2, 3, 5, 7, 11, 13 and 17.

Step Two:

the primes. Label the largest prime Pg+1, and label the next largest prime Pg.

Label the smallest prime P1, the next consecutive prime P2, etc, up to Pg.

P1 = 2       P4 = 7       Pg+1 = 17

P2 = 3       P5 = 11

P3 = 5       Pg = 13

Step Three:

Divide the primes P1 through Pg up into two groupings. The primes may be divided up in any way, with any number of primes in each grouping. No prime may be put in both groupings. A grouping may consist of as few as one prime.

We will arbitrarily divide up the primes into the following two groupings.

G1 = {2, 3, 11}

G2 = {5, 7, 13}

 Step Four:

Multiply the primes in each grouping together to form a product of all the primes in each grouping. We will call these products, product A and product B. Any prime in each product may be raised to any integral power greater than 1.

Let A = the product of the primes in G1. 

Let B = the product of the primes in G2.

A = (2)3(3)(11) = 264

B = (5)(7)(13) = 455

 Step Five:

Find (Pg+1)2 , which is the upper limit of the range of guaranteed primality.

(Pg+1)2 = (17)2 = 289

Step Six:

Find N, which is the absolute value of the difference of A and B. It can easily be proven that the difference of A and B cannot contain as a factor, any prime factor of either A or B. If N is greater than 1 but less than (Pg+1)2, then N is guaranteed by the theorem to be prime.

N = |A – B| = | 264 - 455 | = 191

Since N = 191 is less than (Pg+1)2 = 289 and greater than 1, 191 is within the range of guaranteed primality and thus should be prime.

Checking 191 in a number table verifies that it is prime.

Informal Proof for Example #1:  

Any integer less than (17)2 = 289, but greater than 1, must either be a prime or be a composite with a prime factor less than 17. Since no integer with a prime factor less than 17 can be produced by the configuration of the prime number producing formula of Example #1, all integers produced by the formula in this configuration that are greater than 1, but less than 289, must be prime.

Numerical Example #2 of the Use of the Prime Number Producing Formula.

Step One:

List a series of consecutive small prime numbers, starting with the smallest prime in the number system (2).

Our series is: 2, 3, 5, 7, 11, 13 and 17.

Step Two:

Label the primes. Label the largest prime Pg+1, and label the next largest prime Pg .

Label the smallest prime P1, the next consecutive prime P2, etc, up to Pg.

P1 = 2        P4 = 7        Pg+1 = 17

P2 = 3        P5 = 11

P3 = 5       Pg = 13

Step Three: 

Divide the primes P1 through Pg up into two groupings. The primes may be divided up in any way, with any number of primes in each grouping. No prime may be put in both groupings. A grouping may consist of as few as one prime.

We will arbitrarily divide up the primes into the following two groupings.

G1 = {3, 13}

G2 = {2, 5, 7, 11}

Step Four:

Multiply the primes in each grouping together to form a product of all the primes in each grouping. We will call these products, product A and product B. Any prime in each product may be raised to any integral power greater than 1.

Let A = the product of the primes in G1.

Let B = the product of the primes in G2.

A = (3)(13)2 = 507

B = (2)(5)(7)(11) = 770

Step Five:

Find (Pg+1)2 , which is the upper limit of the range of guaranteed primality.

(Pg+1)2 = (17)2 = 289

 Step Six:

Find N, which is the absolute value of the difference of A and B. It can easily be proven that  the difference of A and B cannot contain as a factor, any prime factor of either A or B. If N is greater than 1 but less than (Pg+1)2, then N is guaranteed by the author’s theorem to be prime.

N = |A – B| = | 507 - 770 | = 263 

Since N = 263 is less than (Pg+1)2 = 289 and greater than 1, 263 is within the range of guaranteed primality and thus should be prime.

Checking 263 in a number table verifies that it is prime.

Informal Proof for Example #2:

Any integer less than (17)2 = 289, but greater than 1, must either be a prime or be a composite with a prime factor less than 17.  Since no integer with a prime factor less than 17 can be produced by the configuration of the prime number producing formula of Example #2, all integers produced by the formula in this configuration that are greater than 1, but less than 289, must be prime.

Numerical Example #3 of the Use of the Prime Number Producing Formula.

Step One:

List a series of consecutive small prime numbers, starting with the smallest prime in the number system (2).

Our series is: 2, 3, 5, 7, 11, 13, 17 and 19.

Step Two:

Label the primes. Label the largest prime Pg+1, and label the next largest prime Pg.

Label the smallest prime P1, the next consecutive prime P2, etc, up to Pg.

P1 = 2       P4 = 7       Pg = 17

P2 = 3       P5 = 11      Pg+1 = 19

P3 = 5       P6 = 13

 Step Three:

Divide the primes P1 through Pg up into two groupings. The primes may be divided up in any way, with any number of primes in each grouping. No prime may be put in both groupings. A grouping may consist of as few as one prime.

We will arbitrarily divide up the primes into the following two groupings.

G1 = {3, 7, 17}

G2 = {2, 5, 11, 13}

Step Four:

Multiply the primes in each grouping together to form a product of all the primes in each grouping. We will call these products, product A and product B. Any prime in each product may be raised to any integral power greater than 1.

Let A = the product of the primes in G1.

Let B = the product of the primes in G2.

A = (3)2(7)(17) = 1071

B = (2)(5)(11)(13) = 1430

Step Five:

Find (Pg+1)2, which is the upper limit of the range of guaranteed primality.

(Pg+1)2 = (19)2 = 361

 Step Six:

Find N, which is the absolute value of the difference of A and B. It can easily be proven that the difference of A and B cannot contain as a factor, any prime factor of either A or B. If N is greater than 1 but less than (Pg+1)2, then N is guaranteed by the author’s theorem to be prime.

N = |A – B| = | 1071 - 1430 | = 359

Since N = 359 is less than (Pg+1)2 = 361 and greater than 1 , 359 is within the range of guaranteed primality and thus should be prime.

Checking 359 in a number table verifies that it is prime.

Informal Proof for Example #3:

Any integer less than (19)2 = 361, but greater than 1, must either be a prime or be a composite with a prime factor less than 19.  Since no integer with a prime factor less than 19 can be produced by the configuration of the prime number producing formula of Example #3, all integers produced by the formula in this configuration that are greater than 1, but less than 361, must be prime.

Generalized Form of the Informal Proof:

Any integer less than (Pg+1)2, but greater than 1, must either be a prime or be a composite with a prime factor less than Pg+1.  Since no integer with a prime factor less than Pg+1 can be produced by the prime number producing formula, all integers produced by the formula that are greater than 1, but less than (Pg+1)2, must be prime.

The Author’s Prime Number Theorem and Its Formal Proof

In this derivation all literal quantities represent only positive real numbers.

Given two natural numbers, N and K, where K > N and N > 1.

Theorem 1 (a well known theorem):  If  N is a composite number,  then N has at least one prime factor  <sqrt( N).

If  K > N,  then  sqrt( K)  > sqrt( N).

Theorem 2: If N is a composite number, then N has at least one prime factor < sqrt (K).

Theorem 3: If N has no prime factor < sqrt( K) , then N is not composite.

Since a natural number >1 must be either prime or composite, we obtain Theorem 4, the author’s prime number theorem.

Theorem 4: Given two natural numbers, N and K, where K > N and N > 1, if N has no prime factor < sqrt( K), then N is prime.  

References

Two articles on prime numbers and prime number formulas that the reader should find helpful in understanding this paper are the following:

Underwood Dudly, “Formulas for Primes,” Mathematics Magazine, 17-22, 1983.

A. Dewdney, “How to Pan for primes in Numerical Gravel,” Scientific American, 121, July 1988   

Appendix. Some Special Techniques that Make the Generation of Larger Primes Easier

These techniques modify the original algorithm, but they make finding N values small enough to be guaranteed prime a lot easier.

Technique #1Leaving 2 and 5 out of A and B.

Leaving 2 and 5 out of the two products allows either or both 2 and 5 to appear as factors of N. If one or both of these primes is a factor of an integer, this fact shows up in the last digit of the integer, which will be either even or 5. Dividing all the 2's and 5’s out of the integers (N values) produced by my algorithm will leave factors that are guaranteed prime if they are less than (Pg+1)2 , but greater than one.

Technique #2: Multiplying A by a factor and / or multiplying B by a factor.

This technique involves multiplying A by a factor, which is a prime larger than Pg, or a product of primes, each prime being larger than Pg, and/or multiplying B by the same kind of factor. Each multiplier for A must contain no prime factor contained in the multiplier for B, and vice versa.

These techniques will not change the fact that the N values produced will contain no prime factor (except for 2 and 5) smaller than Pg+1. These techniques produce some impressive results, as shown below.

In the calculations below, the first integer below the dotted line is N, the absolute value of the difference of the two products, while the integer immediately below this is the prime factor obtained after all 2’s and 5’s have been divided out of N. For the calculations in the grouping immediately below,
Pg+1 = 29 and (Pg+1)2 = 841.

  (3)(7)(11)(23) = 5313           (3)(7)(11)(23)2 = 122199              (17)(19)(23)2 = 170867

  – (17)(13)(19) = – 4199             – (17)(13)(19) = – 4199        – (3)(7)3(11)(13) = –147147

                             --------                                  ---------                                    ---------

                               1114                                    118000                                    23720     

                                 557 prime                            59 prime                                 593 prime

 

 

                (17)2(19)(23) = 126293                             (3)2(7)(11)2(23) = 175329                 

 – (3)(7)(11)(13) (41) = – 123123                     – (17)(13)(19)(41) = – 172159                            

                                        ---------                                                          ----------

                                            3170                                                               3170

                                             317 prime                                                       317 prime

 

 

             (17)(19)2(23) = 141151                                           (3)(7)(11)(23) = 5313

 – (3)(7)(11)(13)(37) = –111111                                       – (13)(17)(19) = – 4199

                                      ---------                                                                   ---------

                                        30040                                                                     1114

                                            751 prime                                                              557 prime

 

  

             (13)2(17)(19) = 54587                                                (3)(7)(11)2(23) = 58443

    –  (3)3(7)(11)(23) = – 47817                                             – (13)2(17)(19) = – 54587

                                      --------                                                                          ----------

                                       6770                                                                               3856

                                          677 prime                                                                     241 prime

 

 

  

  (3)(7)3(11)(23) = 260337                                        (3)(7)(11)(23)(59) = 313467

– (13)2(17)(19) = – 54587                                             – (13)2(17)(19) = – 54587

                                -------                                                                           --------

                             205750                                                                           258880

                                   823 prime                                                                        809 prime

 

 

 For the calculations in the grouping below,  Pg+1 = 37 and (Pg+1)= ( 1369).

     (3)(7)(11)(13)2(17) = 663663                   (3)2(11)(17)(19)(59) = 1886643

  – (19)(23)(29)(31) = – 392863               – (7)(13)(23)(29)(31) = – 1881607

                                     ----------                                                        ------------

                                      270800                                                              5036

                                      677 prime                                                        1259 prime

 

  

     (3)(11)(17)(31)(73) = 1269543                                 

 – (7)(13)(19)(23)(29) = – 1153243                              

                                       ------------                                                                   

                                           116300                                                                        

                                           1163 prime   

 

   
Copyright 2005 by Society for Amateur Scientists