Prime numbers – mysterious, fascinating, and an integral part of the history of mathematics. From ancient times to modern times, mathematicians have tried to unravel their mysteries, discovering many important theories and theorems in the process. In this article, we will take a closer look at these unique numbers, which form the foundation of mathematics, and present completely new methods for generating them, as well as solving the problem of the distribution of prime numbers.

The information presented below related to the use of two simple formulas and trigonometric functions will allow us to learn the principle of how prime numbers are formed and predict their occurrence without any operations related to primality testing. In short, we will discover the long sought-after code of prime numbers.

### MATHEMATICAL FORMULA

The following formula defines an infinite sequence of primes without the need for any factorization:

**{ (2), (3), (5), (6m+1), (6n-1) | m > 0, m mod 10 ≠ 4, m mod 10 ≠ 9, n > 0, n mod 10 ≠ 1, n mod 10 ≠ 6} \ {(6m+1)*(6n-1), (6m+1)*(6m+1), (6n-1)*(6n-1) | m > 0, m mod 10 ≠ 4, m mod 10 ≠ 9, n > 0 , n mod 10 ≠ 1, n mod 10 ≠ 6}**

Generating prime numbers always starts with the number 1 and goes to infinity.

As we will see from the numbers generated from the formulas *6m+1* and *6n-1,* we subtract the products and squares of the numbers from these formulas. We will call the products and squares of prime numbers nearprime numbers (more information in the section NEAR-PRIME NUMBERS). The result of removing near-prime numbers from the sets of 6m+1 and 6n-1 is obtaining all prime numbers without any factorization.

### How are prime and near-prime numbers formed?

The most optimal formulas for determining two numerical sequences in which over 66.66% of natural numbers are omitted and which will determine all prime (except numbers 2 and 3) and near-prime numbers are:

* 6n+1* oraz

*where n > 0*

**6n-1**_{{(6n-1), (6n+1) | n > 0}}

Numbers from the set *6n+1* :

*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 the set *6n-1* :

*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,…*

A strong argument is that 50% of all numbers in the Fibonacci sequence are numbers from the discussed formulas 6n-1 and 6n+1. More information in the section FIBONACCI SEQUENCE. The numbers from the discussed patterns also create a symmetrical and repeatable spiral, the effect can be seen here.

### Finding consecutive prime numbers using trigonometric functions.

As we can see in the image below, we place our two sets of prime and “near-prime” numbers on the X-axis. Starting from the point of intersection of the X and Y axes, we place the numbers from the formula *6n-1* to the left, and the numbers from the formula *6n+1* to the right.

Now, we are aided by a suitably modified trigonometric function, such as the sine function. We determine the sine wave that intersects the X-axis every 5 positions to the right and left of our smallest number, which is “5” (marked by a green dot). The image below shows the result of this operation:

As we can see above, the places where the sine wave intersects the X-axis (except for the number 5 because we used it to determine the sine wave) are our “near-prime” numbers, which are not prime numbers because they are either squares of prime and/or “near-prime” numbers or their products. As we can see, the next number greater than “5” is the number “7”, and even before determining the next sine wave, we can confidently state that all natural numbers on our X-axis smaller than the value of the square of the number “7”, i.e. smaller than “49”, which the sine wave does not pass through (except for the number 5 because we used it to determine the sine wave so far), are prime numbers. The next step will be to determine the sine wave that will intersect the X-axis every seven positions from the number “7”.

Again, we see that all natural numbers through which none of the sine waves determined so far pass (except for the numbers 5 and 7 because we used them to determine the sine waves so far) – smaller than the value of “121” (i.e. the square of the next number in our series, which is the number “11”) are certainly the next prime numbers.

By using this method to infinity, i.e. from the number “5” determining a sine wave that intersects the X-axis every five positions, from the number “7” a sine wave that intersects the X-axis every seven positions, from the number “11” a sine wave that intersects the X-axis every eleven positions, etc., we accurately determine prime numbers from the top down, smaller than the value of the square of the next number from which we stopped determining the sine wave.

All natural numbers smaller than the square of the next number from which we stopped determining the sine wave and at the same time greater than the number from which we stopped determining the sine wave on our X-axis, through which at least one sine wave has passed, are not prime numbers (of course, except for the numbers from which we determined the sine wave). It is important to remember to determine the sine wave gradually, i.e. first from the number “5”, then “7”, “11”, “13”, “…”.

Some may argue that this is a modified version of the Sieve of Eratosthenes, but there is no sieve that would define the next prime numbers smaller than the square of that number in the set we would be checking, even before checking a particular number (or a sequence of numbers).

One can use a method that involves all natural numbers to determine consecutive prime numbers, where the same principle applies that after determining the sine wave from a particular number, all numbers smaller than the square of the next natural number through which the sine wave does not pass are prime numbers. However, this method forces us to perform operations on all natural numbers, as can be seen in the image below;

### HYPOTHESES

The code of prime numbers and the way they are generated was discovered thanks to trigonometric functions (basically multiplication), which is much more efficient for calculations by computers than complicated mathematical calculations such as prime number factorization and division. In addition, the use of formulas *6n-1* and *6n+1* reduces the search for prime numbers to 26.66% of all natural numbers (assuming that we eliminate from our set numbers greater than five ending in the digit 5).

All squares of prime numbers from the 6n+1 and 6n-1 sets always occur only in the 6n+1 set. In addition, the product of two primes belonging to the same set is always in the set 6n+1. The sum of the digits of a number in the set 6n+1 is 1, 4 or 7.

The set 6n-1 contains more prime numbers because it also contains only products of prime numbers where one factor is always the number from the set 6n-1 and the second factor is the number from the set 6n+1. The sum of the digits of a number belonging to the set 6n-1 is 2, 5 or 8.

Each prime number with the sum of digits 2, 5 or 8, i.e. from the set 6n-1, to check whether it is a prime number, it is enough to divide only by numbers from the set 6n-1 or 6n+1, which are smaller than the root of the number being checked, which speeds up obtaining answer whether it is a prime number.

A prime number (or a near-prime number) (except the number 3) will never have the sum of the digits 3, 6 and 9.

Let me remind you that Nikola Tesla considered the numbers 3, 6 and 9 special.

A prime or near-prime number (except 3) will never have the sum of the digits 3, 6, and 9. Let me remind you that Nikola Tesla considered the numbers 3 , 6 and 9 for exceptional.

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