1
$\begingroup$

I have derived the following theorem:

An odd positive integer $N=6n−1$ is a prime iff neither of two diophantine equations

$6x^2+(6x−1)y=n$

$6x^2+(6x+1)y=n$

has solution.

An odd positive integer $N=6n+1$ is a prime iff neither of two diophantine equations

$6x^2−2x+(6x−1)y=n$

$6x^2+2x+(6x+1)y=n$

has solution.

$x=1,2,3,\ldots;y=0,1,2,\ldots;n=1,2,3,\ldots$

Theorem allows to substitute the task: "Find all primes in the range $(N_1;N_2)$" by the task: "Find positive integers which do not appear in the range $(n_1;n_2)$ in two pairs of $2$-dimensional arrays

$P_1(i,j)=6i^2+(6i-1)(j-1)$

$P_2(i,j)=6i^2+(6i+1)(j-1)$

$i,j = 1,2,3,\ldots$

for primes in the sequence $N=6n-1$.

$P_3(i,j)=6i^2-2i+(6i-1)(j-1)$

$P_4(i,j)=6i^2+2i+(6i+1)(j-1)$

$i,j = 1,2,3,\ldots$

for primes in the sequence $N=6n+1$. Since all primes (except $2$ and $3$) are in one of two forms $6n−1$ or $6n+1$, so we can find primes simply by picking up positive integers which do not appear in these arrays and we need not to perform operations of dividing. See http://www.planet-source-code.com/vb/scripts/BrowseCategoryOrSearchResults.asp?lngWId=3&blnAuthorSearch=TRUE&lngAuthorId=21687209&strAuthorName=Boris%20Sklyar&txtMaxNumberOfEntriesPerPage=25

Can proposed algorithm be regarded as an alternative to sieve of Eratosthenes?

$\endgroup$
2
  • $\begingroup$ Assuming the assertions are formally proved correct, it would seem then to be an alternative. Even so, it is unclear to me what benefits there are. Can you use it to test for a prime quickly? Can you say something new about the distribution of primes with it? Until you are able to convince me of its potential, I will focus on my own prime finding algorithms. Gerhard "Not Sure Of The Applicability" Paseman, 2020.01.07. $\endgroup$ Jan 7, 2020 at 17:21
  • $\begingroup$ Theoretical background and C++ code - see academia.edu/13890086/… program calculates primes in interval of 10^6 for numbers up to 10^19 for run time of 10 sec $\endgroup$ Jan 7, 2020 at 17:27

1 Answer 1

1
$\begingroup$

You can simplify by using just one matrix $$P(i,j)=6ij+i-j$$ with $i\geq 2$ and $j\geq 1$

We can find primes (except $2$ , $3$ and $5$) simply by picking numbers $k>1$ which do not appear in this array (except $21$) with:

$p= \frac{(6k-1)}{5}$ if $k\equiv 1 \bmod 5$

and

$p=6k-1$ otherwise

However a faster method is obtained using this code in python:

n=10000000
primes5m6 = [True] * (n//6+1)
primes1m6 = [True] * (n//6+1)
for i in range(1,int((n**0.5+1)/6)+1):
    if primes5m6[i]:
        primes5m6[6*i*i::6*i-1]=[False]*((n//6-6*i*i)//(6*i-1)+1)
        primes1m6[6*i*i-2*i::6*i-1]=[False]*((n//6-6*i*i+2*i)//(6*i-1)+1)
    if primes1m6[i]:
        primes5m6[6*i*i::6*i+1]=[False]*((n//6-6*i*i)//(6*i+1)+1)
        primes1m6[6*i*i+2*i::6*i+1]=[False]*((n//6-6*i*i-2*i)//(6*i+1)+1)

where for $i>0$

$ p = 6i-1 $ is prime if $ primes5m6 [i] = True $

and

$ p = 6i + 1 $ is prime if $ primes1m6 [i] = True $

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.