0
$\begingroup$

In this question a user asks for an arithmetic progression $$a, a+d, a+2d,\cdots, a+(n-1)d$$ for $a=101$ and $n=6$ such that all $a+id$ are prime numbers. $3990$ is such a $d$ and it was found by a Haskell program by Wolfram published as answer to this question. The sequence
$$7,37,67,97,127,157$$ for $n=6$ and $a=7$ is published in a comment by lulu to the question.

For $a=199$ this answer by Dietrich Burde shows the sequence $$a_k=199+210k, k=0,\cdots,9$$ which gives $$199,409,619,829,1039,1249,1459,1669,1879,2089, 199,409,619,829,1039,1249,1459,1669,1879,2089 $$

The Green-Tao-Theorm states that there are aritmethic progressions of arbitrary length that contain only primes.

The following Python program that uses the same algorithm as the Haskell program in the referenced post finds $d=3990$ immediately on my notebook.

def is_prime(n):
    # check by trial division if n is prime
    if n<=1:
        return(False)
    else:
        for i in range(2,int(n**.5)+1,2):
            if n%i==0:
                return(False)
        else:
            return(True)
def find_d(a,n):
    # for d=1,2,3,...  test if the arithmetic progression 
    # a+d, a+2*d, …, a+(n-1)*d contains only primes
    d=1
    while True:
        # test arithmetic progression for the next d
        # if an element is not prime, you can skip 
        # this arithmetic progression and 
        # check the next d
        # if an approprate t is found then return it
        # and stop

        d+=1
        all_are_prime=True
        for i in range(1,n):
            if not is_prime(a+i*d):
                all_are_prime=False
                break
        if all_are_prime:
            return(d)            

I ran it for larger $d$ and found the following $d$ that are minimal for $n$.

n        d     size  sec
6     3990   5*10^3    0
7  1683990     10^6   16
8  3227070   5*10^6   43
9  9649080     10^7  160

Running this program with argument §n=10$ didn't give a result within 6 hours, and so I aborted the program.

I ran another program that calculated the numbers $d=54153939840$, $d=785714631660$, $d=169346689470$ for $n=10$. But I found out that the program has some bugs so I am not sure if $d=54153939840$ is the smallest number for $n=10$.

My Question: For $a=101$ how can I calculate $d$ efficiently for $n=10$ and larger $n$ and what is the expected number of operation the algorithm needs. Especially if a search algorithm is involved as in the program above this means what is the expected size of the smallest $d$ for a given $n$?

I plan to post my solution to this question as soon I have found time to repair the program and write an answer.

  • 0
    What was the algorithm for another program?2017-02-08
  • 0
    see also here http://mathworld.wolfram.com/PrimeArithmeticProgression.html2017-02-08
  • 0
    Using congruences mod $3$, $5$ and $7$ is easy to see that $210\mid d$. This reduces the search. Another improvement would be to use a better algorithm to check for primeness of $101+k\,d$.2017-02-08
  • 0
    Programming in Mathematica I have found in less than a minute $d=10\,269\,306\,390$ for $n=10$.2017-02-08
  • 0
    @Wolfram additionally to the improvements proposed by Julián Aguirre (2m3m5,7 and prime algorithm) I used the primes 11, 13, 17, 19.2017-02-08
  • 0
    Here is another wiki link https://en.wikipedia.org/wiki/Primes_in_arithmetic_progression2017-02-08
  • 0
    @JuliánAguirre So your program checked 10269306390 / 210 ~ 5*10^6 numbers for primality? Did you try larger n, e.g sequences of length 11,12,13,...? Do you have an estimate for d if n=11,12,13?2017-02-09
  • 0
    For $n=11$ I get $d=782\,605\,553\,730$ in 1799 seconds. I hope to be able to report $n=12$ tomorrow.2017-02-09
  • 0
    For $n=12$ $d=4\,162\,186\,447\,650$ in $9\,804$ seconds.2017-02-10
  • 0
    @JuliánAguirre did you search for 4162186447650 as a multiple of (11*7*5*3*2) ? Then you checked 180000 numbers per seconds. If you searched for 4162186447650 as a multiple of (7*5*3*2) then you checked 2000000 numbers per seconds. if you searched 782605553730 as a multiple of (7*5*3*2) then you also checked 2000000 numbers per seconds. So I suspect you searched for 4162186447650 as a multiple of (7*5*3*2). Is this true or does the prime test take so much longer for the large numbers?2017-02-10
  • 0
    @JuliánAguirre I tried to estimate the sizof $d$ \begin{array}\\ n & d \\ 5 & 2.2 \times 10^{2} \\ 6 & 1.6 \times 10^{3} \\ 7 & 1.4 \times 10^{5} \\ 8 & 1.4 \times 10^{6} \\ 9 & 1.7 \times 10^{7} \\ 10 & 2.6 \times 10^{8} \\ 11 & 5.3 \times 10^{10} \\ 12 & 9.2 \times 10^{11} \\ 13 & 2.3 \times 10^{14} \\ 14 & 4.6 \times 10^{15} \\ 15 & 1 \times 10^{17} \\ 16 & 2.6 \times 10^{18} \\ 17 & 1.1 \times 10^{21} \\ 18 & 3.1 \times 10^{22} \\ 19 & 1.6 \times 10^{25} \\ \end{array}2017-02-10
  • 0
    I searched for multiples of $2\cdot3\cdot5\cdot7\cdot11$. Of course prime checking takes longuer for larger integres.2017-02-10
  • 0
    @JuliánAguirre d=3963900061110990 for n=13 after 40000 seconds with my repaired progam. At the moment am not sure if it is the smallest d becuase the program is still running. I am using all primes from 2 to 31 for this calculation. I think n>=14 isn't possible in a reasonable amount of time with my current program on my notebook.2017-02-12
  • 0
    I was doing the calculations for $n=13$ with the products of the primes up to $13$. I have stopped it after 90 hours.2017-02-13

0 Answers 0