PRIME NUMBERS CODE

Prime numbers – mysterious, fascinating and inseparable from the history of mathematics. From ancient times to modern times, mathematicians have been trying to solve their riddles, thus discovering many important theories and theorems.

The information presented below will allow us to learn the principle of how prime numbers are created and to predict their error-free occurrence without any actions related to the primality test. In short, we will learn the long-sought prime number code.

PRIME NUMBERS PATTERN

The following formula defines the set of prime numbers:

\( P = (A \cup B) \setminus C \)

\( where: \)

\( \mathbb{A} = \{ 2, 3 \} \)

\( \mathbb{B} = \{ 6k±1 \mid k \in \mathbb{N}, k \geq 1, \lim_{k \to \infty} \} \)

\( \mathbb{C} = \left\{ p \cdot q \mid p,q \in \mathbb{B} \right\} \)

Below is the optimized formula for determining prime numbers for a given range:

\( P = (A \cup B \cup C) \setminus (D \cup E \cup F) \)

\( where: \)

\( \mathbb{A} = \{ 2, 3, 5 \} \)

\( \mathbb{B} = \{ 6k+1 \mid k \in \mathbb{N}, k \geq 1, k \leq \frac{x}{6}, k \mod 10 \notin \{ 4, 9 \} \} \)

\( \mathbb{C} = \{ 6k-1 \mid k \in \mathbb{N}, k \geq 2, k \leq \frac{x}{6}, k \mod 10 \notin \{ 1, 6 \} \} \)

\( \mathbb{D} = \{ (6k_1 + 1)(6k_2-1) \mid k_1, k_2 \in \mathbb{N}, k_1 \geq 1, k_2 \geq 2, k_1 \leq \frac{x}{42}, k_2 \leq \frac{x}{6(6k_1 + 1)}, k_1 \mod 10 \notin \{ 4, 9 \}, k_2 \mod 10 \notin \{ 1, 6 \} \} \)

\( \mathbb{E} = \{ (6k_1 + 1)(6k_2 + 1) \mid k_1, k_2 \in \mathbb{N}, k_1 \geq 1, k_2 \geq 1, k_1 \leq \frac{x}{42}, k_2 \leq \frac{x}{6(6k_1 + 1)}, k_1 \mod 10 \notin \{ 4, 9 \}, k_2 \mod 10 \notin \{ 4, 9 \} \} \)

\( \mathbb{E} = \{ (6k_1-1)(6k_2-1) \mid k_1, k_2 \in \mathbb{N}, k_1 \geq 2, k_2 \geq 2, k_1 \leq \frac{x}{66}, k_2 \leq \frac{x}{6(6k_1 – 1)}, k_1 \mod 10 \notin \{ 1, 6 \}, k_2 \mod 10 \notin \{ 1, 6 \} \} \)

\( where \ x \ is \ the \ maximum \ value \ of \ the \ number \ in \ the \ generated \ set \)

Python script that reflects the above formula for x = 1,000,000:

Simplified version of the script:

Set A contains the numbers 2, 3 and 5.
The set B contains numbers of the form 6k+1 with some exceptions up to a fixed range k.
The set C contains numbers of the form 6k-1 with some exceptions up to a fixed range k.
The set D contains the products of all possible combinations of numbers from the patterns 6k-1 and 6k+1 up to a fixed range k.
The set E contains the products of all possible combinations of numbers from the patterns 6k+1 up to a fixed range x.
The set F contains the products of all possible combinations of numbers from the patterns 6k-1 up to a fixed range k.

As we can see, after removing from sets A∪B∪C all numbers that are in sets D∪E∪F we obtain a set P that contains only prime numbers up to a fixed range x.

I took the liberty of calling the numbers from the sets D∪E∪F near-prime numbers, which we will learn more about in the NEAR-PRIME NUMBERS section.

Since there are formulas for the sets of numbers (A∪B∪C) and (D∪E∪F), it becomes logical that the set of prime numbers P can also be expressed as a formula.

To illustrate these assumptions in an easy graphical way, we will use the Ulam spiral, which is represented by the formula:

\( P = (A \cup B \cup C) \setminus (D \cup E \cup F) \)

Then we create spirals with the products of prime numbers of the form 6k±1, i.e. with numbers from the set:

\( (D \cup E \cup F) = (A \cup B \cup C) \setminus P \)

Ulam spiral (left) vs. spiral with numbers from sets D∪E∪F (right)

Now we superimpose the Ulam spirals on the spirals with numbers from the sets D∪E∪F. The result can be seen below:

We obtained spirals with a symmetrical arrangement of prime and near-prime numbers, i.e. with numbers from the formula:

\( (A \cup B \cup C) = P \cup (D \cup E \cup F) \)

This symmetrical spiral structure proves that the occurrence of prime numbers is completely predictable and that prime numbers can be represented with full certainty in the form of the following pattern:

\( P = (A \cup B \cup C) \setminus (D \cup E \cup F) \)

An important aspect of the existence of a relatively symmetrical spiral with numbers in the form 6k±1 is the fact that we can not only more easily predict the future locations of prime numbers, but we also have an easier possibility of factoring near-prime numbers which are the values ​​of n in the RSA algorithm. Details coming soon, and as an incentive, I present a prime number of 101 million digits available for download here.

Alternative version of the formula:

\( P = (A \cup B \cup C) \setminus (D \cup E) \)

\( where: \)

\( \mathbb{A} = \{ 2, 3, 5 \} \)

\( \mathbb{B} = \{ 6k+1 \mid k \in \mathbb{N}, k \geq 1, k \leq \frac{x}{6}, k \mod 10 \notin \{ 4, 9 \} \} \)

\( \mathbb{C} = \{ 6k-1 \mid k \in \mathbb{N}, k \geq 2, k \leq \frac{x}{6}, k \mod 10 \notin \{ 1, 6 \} \} \)

\( \mathbb{D} = \left\{ p^2 + p \cdot n \mid p \in \mathbb{B}, \quad p < \sqrt{\max(\mathbb{B})}, \quad (p^2 + p \cdot n) \bmod 10 \notin \{ 5 \}, \quad n \in 2\mathbb{N}_0 \setminus (2 + 6\mathbb{N}) \right\} \)

\( \mathbb{E} = \left\{ p^2 + p \cdot n \mid p \in \mathbb{C}, \quad p < \sqrt{\max(\mathbb{B})}, \quad (p^2 + p \cdot n) \bmod 10 \notin \{ 5 \}, \quad n \in 2\mathbb{N}_0 \setminus (4 + 6\mathbb{N}) \right\} \)

\( where \ x \ is \ the \ maximum \ value \ of \ the \ number \ in \ the \ generated \ set \)

Python script that reflects the above formula for x = 1,000,000:

Modified Sieve of Eratosthenes

Let us first determine two sets of numbers in which more than \( \frac{2}{3} \) natural numbers are omitted and which determine all prime numbers (except 2 and 3) and also determine the near-primes:

\( B = \{ 6k+1 \mid k \in \mathbb{N}, k \geq 1, k \leq x \} \)

\( C = \{ 6k-1 \mid k \in \mathbb{N}, k \geq 1, k \leq x \} \)

\( where \ x \ is \ the \ maximum \ value \ of \ the \ number \ in \ the \ generated \ set \)

Numbers from set B:

{7, 13, 19 ,25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115, 121, 127, 133, 139, 145, 151, 157, 163, 169, 175, 181, 187, 193, 199, 205, 211, 217, 223,…}

Numbers from set C:

{5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 107, 113, 119, 125, 131, 137, 143, 149, 155, 161, 167, 173, 179, 185, 191, 197, 203, 209, 215, 221,…}

An interesting fact is that 50% of all numbers in the Fibonacci sequence are numbers from the discussed 6k±1 patterns, more information in the FIBONACCI SEQUENCES section.

Determining consecutive prime numbers using trigonometric functions.

As we can see in the image below, we place our two sets of numbers on the X coordinate axis. From the point of intersection of the X and Y axes to the left side we place numbers from the pattern 6k-1, while to the right side we place numbers from the pattern 6k+1.

sinusoida1

At the very beginning, I would like to emphasize that the operations described below must always start from the number “5” and perform them gradually on the next number greater than the previous one, i.e. 5, 7, 11, 13, 17, 19, 23, 25… etc.

We determine from our smallest number, i.e. from the number “5” a sine wave that intersects the X axis every 5 positions. In the image below we can see the effect of this operation:

sinusoida2

As we can see above, all natural numbers on our X-axis greater than the number from which we determined the last sine wave (in this case greater than the number 5) and through which the sine wave runs are always numbers that are not prime numbers, because they are products or squares of prime and/or near-prime numbers.

Predicting the occurrence of prime numbers.

All natural numbers on our X axis greater than the numbers from which we have already determined the sine wave, and at the same time less than the value of the square of the next number are prime numbers if no sine wave intersects them.

Additionally, all natural numbers on our X axis less than or equal to the value from which we determined the last sine wave that are intersected by only one sine wave are also prime numbers.

So, as we can see in the image below, in this case all numbers greater than 7 and less than the square of the next number, i.e. 112 = 121, which are not intersected by any sine wave, are prime numbers. Additionally, all numbers less than or equal to the number from which we determined the last sine wave, i.e. the number “7” which is intersected by only one sine wave, are also prime numbers.

sinusoida5

We use this method strictly following the rule that we always start the calculations from the number “5“, determining the sine wave that intersects the X axis every five positions, from the number “7” the sine wave intersecting the X axis every seven positions, from the number “11” the sine wave intersecting the X axis every eleven positions, from the number x the sine wave intersecting the X axis every x positions.

It should be emphasized that although the above method has the characteristics of the Sieve of Eratosthenes, it only operates on \( \frac{1}{3} – 1 \) natural numbers (because we omit \( \frac{2}{3} \) natural numbers and the number 1). Additionally, it is distinguished by the fact that it correctly defines subsequent prime numbers smaller than the value of the square of the next number, without the need for any primality tests. The higher the target value of x, the fewer logarithmically we have to perform sine wave drawings, because the difference in the number of numbers between the number x and its root grows exponentially.

To find primes up to \(x\), it is necessary to determine the sinusoids of to the numbers up to \( \sqrt{x}​ \) . This means that all that needs to be generated is \( \frac{\sqrt{x}}{3} – 1 \) sinusoids.

For example, if we want to obtain prime numbers in the range \( x \leq 1,000,000 \), it is enough to generate sinusoids from numbers up to \( \sqrt{1,000,000} \), i.e. up to \( 1000 \) inclusive. Consequently, we only need to generate \( \frac{\sqrt{1\,000\,000}}{3} – 1 \approx 332 \) sine waves. As a result, after performing just \( \approx 332 \) operations, we can obtain a set of prime numbers in the range from 5 to 1,000,000.

Below we have a simple script written in Python which illustrates the discussed principle of determining prime numbers and generates in the prime.txt file without errors all prime numbers up to the value max_num = 1000001 which must be in the form of 6k±1

Below we have a modified Sieve of Eratosthenes written in Python, which only operates on numbers from the sets of 6k±1, which speeds up the determination of subsequent prime numbers:

HYPOTHESES

Using the patterns 6k±1 limits the search for primes to just \( 26\frac{2}{3}\% \) of all natural numbers (assuming that we eliminate from our set numbers greater than 5 that end with the digit 5).

All prime numbers greater than 3 have the form 6k±1.

All prime squares (greater than 3) always have the form 6k+1.

The squares of primes (except 2 and 5) always end with the digit 1 or 9.

The product of primes having the form 6k+1 always appears only in the set 6k+1.

The product of primes having the form 6k-1 also always appears only in the set 6k+1.

If one prime is of the form 6k+1 and the other is 6k-1, then their product is of the form 6k-1.

Every prime number (greater than 3) is an odd number and its sum of digits can only be
1, 2, 4, 5, 7 or 8.

Prime numbers in the form 6k-1 have the sum of their digits 2, 5 or 8, while numbers in the form 6k+1 have the sum of their digits 1, 4 or 7.

The sum of the digits of a prime number (except for the number 3) will never be 3, 6 or 9.
Let me remind you that Nikola Tesla considered the numbers 3, 6 and 9 to be exceptional.

It is worth noting that the near-prime numbers create the value of the n exponent of the public key in the RSA encryption algorithm. More information in the RSA section.