login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Record lengths of strings of alternating-size differences between neighboring primes.
2

%I #61 Jan 21 2016 14:06:13

%S 2,6,8,13,16,18,19,20,21,26,28,29,31,33,34,35,36,39,40,43,45,52

%N Record lengths of strings of alternating-size differences between neighboring primes.

%C This represents the number of differences in sequence that alternate larger and smaller, so the number of consecutive primes directly involved is 1 larger, with the primes on either end of these strings indirectly involved. The choice not to start this sequence with a(2)=6 is only convention (See A228850). A228850 and A228851 contain the smaller and larger prime, respectively, for each value here, and the first of these contains a fuller explanation in Comments.

%C The values 8, 29 and 33 arise in ties of records (determined by a simple modification of the below program), twice each for the latter two, and the five pairs of terminal primes for these are (401, 449), (9950911, 9951343), (25782257, 25782683), (38397529, 38398177) and (66410677, 66411151).

%C Further terms not expected to be found with current resources, with a search extending one order of magnitude larger in the values at the companion sequences of end-primes (at time of submission).

%e The record at the prime 7 is 2 (by convention), and the difference preceding is 2. From there the differences are 4, 2, 4, 2, 4, 6, ... (primes 11, 13, 17, 19, 23, 29, ...). So, 6 differences alternate before termination with the 2-4-6 triple.

%o (PARI) /* This program produces this sequence's elements followed by the elements of A228850 and A228851, and includes asterisks for each billion searched. */

%o {

%o \\ The variable a is a parity marker. \\

%o \\ c is the length of the string. \\

%o \\ D is the most recent difference. \\

%o \\ d is the new difference. \\

%o p=5;q=7;c=2;D=2;a=0;rec=0;z=10^9;

%o while(1,

%o d=q-p;

%o if(c>1,

%o if((a+c)%2,

%o if(d>D,

%o c++,

%o if(c>rec,

%o rec=c;P=p;

%o for(i=1,c,

%o P=precprime(P-1));

%o print1("\n"c": "P","p));

%o if(d<D,

%o c=2;a=1,

%o c=1)),

%o if(d<D,

%o c++,

%o if(c>rec,

%o rec=c;P=p;

%o for(i=1,c,

%o P=precprime(P-1));

%o print1("\n"c": "P","p));

%o if(d>D,

%o c=2;a=0,

%o c=1))),

%o if(d!=D,

%o c=2;

%o if(d>D,

%o a=0,

%o a=1)));

%o p=q;q=nextprime(q+1);

%o if(q>z,z+=10^9;print1("*"));

%o D=d)

%o }

%Y Cf. A000040, A001223, A036263, A228850, A228851.

%K nonn

%O 1,1

%A _James G. Merickel_, Sep 16 2013