^{1}

^{2}

The article is devoted to actual problems of prime numbers. A theorem that allows generating a sequence of prime numbers is proposed. An algorithm for generating prime numbers has been developed. A comparison of the proposed theorem, with Wilson’s theorem is also provided.

The reason for writing this article was a solution of the ancient problem. This problem in a simplified version is as follows: Slandy a noble woman well-known in the Eastern world lived in ancient times. She had seven daughters. Slandy always wore aтamazing beauty antique necklace of precious pearls, which according to tradition passed from mother-in-law to daughter-in-law. In old age, she told her daughters-in-law: “By inheritance it is time to pass the necklace to someone of you and if I will choose someone of you, the others will be offended. If I choose two of you and divide this necklace exactly into two parts, one pearl will be surplus. This is not a right way plus other fives will feel aggrieved what I don’t want in my old ages. And also, when this necklace is divided into 3, 4 or 5, and 6, in each case one pearl is superfluous. And if I divide it by 7, the pearls split evenly, but this is also impossible, as this necklace according to the covenant of ancestors must be passed to only one daughter-in-law. Therefore I will pass the necklace to whom who will determine how many pearls are in this necklace. Others should not be offended.”

“It is known that the daughter-in-law, who decided this problem called Alkhan-Tumar, which means Necklace-Mascot.

Legend also says that this necklace still exists.”

Naturally today it is not difficult to solve the problem. Let’s first recall Wilson’s theorem which is formulated as: a natural number n > 1 is a prime number if and only if

This formulation implies that

Using criterions for divisibility and properties of natural numbers factorial expansion, we can find a first solution as 301. Obviously, that the solutions of this problem set up an arithmetic progression, the first term of which is equal to 301 and the progression difference is 420. i.e. the sequence of solutions of this problem looks like: 301, 721, 1141, etc.

This example is interesting because, if in this problem we replace last number 7 by number 9, or by any composite number, then this problem has no solution, since a condition of a remainder of 1 will not be fulfilled. In short, this problem has a solution when and only when a final number is a prime number, such as 11, 13,

As you can see, this problem is devoted to the problems of prime numbers. We believe that such problems with some similar formulations can be found in folklores of many nations. This is not surprising, the problems of prime numbers appeared before the Common Era, have been affecting interests of the scientific community for more than 2300 years. Since Eratosthenes, scientists have been gradually progressing, and in recent decades computers appeared to help them. But the main problems of prime numbers are still unsolved.

The solution of the above mentioned problem shows a way for solving the following problem of prime numbers.

Let we solve the following problem.

Suppose we are given an ordered sequence of prime numbers. It is necessary to find a next in order prime number. To solve the problem the following theorem is suggested.

Theorem. If the numbers

It is easy to prove this theorem. For this purpose, it is only necessary to combine Wilson’s theorem with a fundamental theorem of arithmetic (“every natural number greater than 1 can be represented as a product of prime numbers, and this product is unique”). The combination of these theorems makes required proof elementary and obvious. For this purpose, in a first approximation, it suffices to take as a product of all composite numbers less than

Now, using this theorem, we will show an algorithm for solving posed problem.

Suppose we have a sequence of known prime numbers

Let indicate

Lemma. If equality (1) is true, then it is true for a infinite set of whole values of k. Plus a sequence of values of k forms an arithmetic progression, the first member of which is in interval from 1 to

For optimality of the proposed theorem implementation in practice, we need to determine a minimum, i.e. the initial value, of k or at least to identify an interval it belongs to.

For this we consider the ratio of

First we will show, that, if the ratio at any k from 1 to

Suppose an expression

this ratio will be for the next following values of k For this purpose we select a value of

It is obvious, that this expression will not be a whole number, since an addend, as mentioned above, is not a whole number. After that, repeating this procedure similarly for any

This means that, if the ratio in question of Equation (1) is a whole number, then the initial value of k must be in interval from 1 to

We will also show here that when the equality (1) is satisfied, the parameter k takes a set of values that equal to

It is obvious, that the first term is a whole number and the second term, as was shown above, is also a whole number, therefore the ratio in question in the lump is also a whole number.

From the above said it follows that under the equality (1), the parameter k takes is a set of values which, as stated above, form an arithmetic progression. The first term of the progression should be in interval from 1 to

From this moment and further, it is sufficient to know an initial value of parameter k, which is in interval of

Note that expression of Equation (1) includes two conditions:

a) A number

b) A number

Thus, let we have an initial ordered sequence of prime numbers

And, if the conditions of Equations (1a) and (1b) are not met, then we deal with a composite number, i.e. in this case, considered number of

this division result is periodically repeated while sorting parameter k. It can be easily seen after a few steps of cycle by k parameter, and it becomes clear that considered number

Then we proceed to the next odd number. The procedure is repeated again for different values of k.

If even in this case, the selected number is again a composite number, then proceed again to the next odd number. The operation is repeated until the conditions of Equations (1a) and (1b) will not be fulfilled. For clarity, we will show this based on a simple example.

Suppose we have an original sequence of prime numbers

Conducting the series of calculations, we see that a result of division of

not be a whole number. This means that 9 is a composite number. After that for

For completeness of the visualization, we consider one more sequence of prime numbers, with its last term as 23. In this case, first for

fied, i.e. a value of

means that a prime number after 23 will be 29, i.e.

Sometimes it happens, that even at k = 1, we obtain desired results. For example, a value of

the numbers 17 and 19 are twins.

Some answers to the posed problem for a small set of primary prime numbers are given as

In short, if there is a set of primary prime numbers, then while using expression of Equation (1) it is always possible to find the next prime number.

To show diversity to the proposed method, we offer one more elegant algorithm, the essence of which is primarily to find a value of k through existing prime numbers.

For this, we use Chinese remainder theorem, which states: “If natural numbers

It is known that constructive method for proving this theorem allows to solve the following system of linear equations modulo [

n | p_{n} | k | |
---|---|---|---|

1 | 3 | 1 | 3 |

2 | 5 | 4 | 25 |

3 | 7 | 3 | 91 |

4 | 11 | 10 | 2101 |

5 | 13 | 10 | 23101 |

6 | 17 | 2 | 60061 |

7 | 19 | 1 | 510511 |

If sets (

where

i.e.

Now, knowing the solution of Equation (3) we can easily find the values of factor k. It is obvious, that Chinese theorem is true for any sequence of prime numbers since prime numbers are always coprimes in pairs. Then, considering for

Now, by combining the proposed theorem with Chinese theorem, we have from Equations (1)-(6):

Expression of Equation (7) shows that if a sequence of prime numbers is known, we are always able to calculate a value of k in advance. Then, by substituting of calculated value of k in Equation (1), we verify the fulfillment of the conditions of Equations (1a) and (1b). If these conditions are not fulfilled, then a number considered as

In this case algorithm for searching prime numbers in odd numbers series looks as follows.

Step 1. Input values of existing prime numbers

Step 2. For^{st} step

Step 3. Calculate

Step 4. Calculate

Step 5. Using extended Euclid’s algorithm, we find

Results obtained based on Wilson’s theorem | Results obtained based on proposed theorem | |||||
---|---|---|---|---|---|---|

n | k | |||||

1 | 2 | 3 | 1 | 2 | 3 | 4 |

2 | 1 | 0 | 2 | 1 | 1 | 0 |

3 | 2 | 0 | 3 | 2 | 1 | 0 |

4 | 6 | 3 | ||||

5 | 24 | 0 | 5 | 6 | 4 | 0 |

6 | 120 | 1 | ||||

7 | 720 | 0 | 7 | 30 | 3 | 0 |

8 | 5,040 | 1 | ||||

9 | 40,320 | 1 | ||||

10 | 362,880 | 1 | ||||

11 | 3,628,800 | 0 | 11 | 210 | 10 | 0 |

12 | 39,916,800 | 1 | ||||

13 | 479,001,600 | 0 | 13 | 2310 | 10 | 0 |

14 | 6,227,020,800 | 1 | ||||

15 | 87,178,291,200 | 1 | ||||

16 | 1,307,674,368,000 | 1 | ||||

17 | 20,922,789,888,000 | 0 | 17 | 30,030 | 2 | 0 |

18 | 355,687,428,096,000 | 1 | ||||

19 | 6,402,373,705,728,000 | 0 | 19 | 510,510 | 1 | 0 |

20 | 121,645,100,408,832,000 | 1 | ||||

21 | 2,432,902,008,176,640,000 | 1 | ||||

22 | 51,090,942,171,709,400,000 | 1 | ||||

23 | 1,124,000,727,777,610,000,000 | 0 | 23 | 9,699,690 | 3 | 0 |

24 | 25,852,016,738,885,000,000,000 | 1 | ||||

25 | 620,448,401,733,239,000,000,000 | 1 | ||||

26 | 15,511,210,043,331,000,000,000,000 | 1 | ||||

27 | 403,291,461,126,606,000,000,000,000 | 1 | ||||

28 | 10,888,869,450,418,400,000,000,000,000 | 1 | ||||

29 | 304,888,344,611,714,000,000,000,000,000 | 0 | 29 | 223,092,870 | 17 | 0 |

30 | 8,841,761,993,739,700,000,000,000,000,000 | 1 | ||||

31 | 265,252,859,812,191,000,000,000,000,000,000 | 0 | 31 | 6,469,693,230 | 13 | 0 |

32 | 8,222,838,654,177,920,000,000,000,000,000,000 | 1 | ||||

33 | 263,130,836,933,694,000,000,000,000,000,000,000 | 1 | ||||

34 | 8,683,317,618,811,890,000,000,000,000,000,000,000 | 1 | ||||

35 | 295,232,799,039,604,000,000,000,000,000,000,000,000 | 1 | ||||

36 | 10,333,147,966,386,100,000,000,000,000,000,000,000,000 | 1 | ||||

37 | 371,993,326,789,901,000,000,000,000,000,000,000,000,000 | 0 | 37 | 200,560,490,130 | 10 | 0 |

38 | 13,763,753,091,226,300,000,000,000,000,000,000,000,000,000 | 1 | ||||

39 | 523,022,617,466,601,000,000,000,000,000,000,000,000,000,000 | 1 | ||||

40 | 20,397,882,081,197,400,000,000,000,000,000,000,000,000,000,000 | 1 | ||||

41 | 815,915,283,247,898,000,000,000,000,000,000,000,000,000,000,000 | 0 | 41 | 7,420,738,134,810 | 34 | 0 |

Step 6. Calculate the desired value of k by the formula:

Step 7. Check fulfillment of equality (1).

Step 8. Conditional operator works here.

-If conditions of Equations (1a) and (1b) are not met, then considered number

-If conditions of Equations (1a) and (1b) are fulfilled, then

Step 9. Generation of the next prime number

The cycle repeats.

We assume that the process of generating prime numbers based on the proposed theorem is faster than a generation based on Wilson’s theorem.

In case of Wilson’s theorem it is quite difficult to calculate the factorial of (n − 1)!. In fact, if generation is carried out in the area of the large numbers, then calculation of given factorial creates significant difficulties. This is explained by the fact that there are intervals in the sequence of natural numbers which include thousands, millions, billions and even some arbitrarily large number of natural numbers standing in a row, among which there is no prime number. For example, if you set an arbitrary large natural number m, let build a series of numbers ^{10}, then in case of Wilson’s theorem, calculation of the factorial will inevitably lead to a large number of calculations involving a huge amount of large composite numbers. And in case of the proposed theorem calculations are mainly made with prime numbers.

This is clearly illustrated from

The left part of the table provides calculations made for values of from 2 to 41. In the 1^{st} column of left part of the table (case of Wilson’s theorem) all natural numbers are given. In this column cells containing prime numbers which are green highlighted for illustrative purposes. In the 2^{nd} column the calculated values of ^{rd} column provides remainders which take zero values in case of prime numbers.

Similar results, obtained using proposed theorem, are shown in the right part of the table. First column of the right part shows prime numbers. Second column of this part presents calculated values of

^{th} prime number, i.e. up to

A right part of the table shows only those numbers with which the calculations have been made using the proposed method. Comparing the left and right parts of the table, we can see that efficiency, speed, and convenience of the proposed method are beyond question, this is obvious. Plus, for a set of large integers, this obviousness becomes even more than self-evident.

Note again that in case of Wilson’s theorem the complexity lies in calculation of