

A229056


Record lengths of strings of alternatingsize differences between neighboring primes.


2



2, 6, 8, 13, 16, 18, 19, 20, 21, 26, 28, 29, 31, 33, 34, 35, 36, 39, 40, 43, 45, 52
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,1


COMMENTS

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.
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).
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 endprimes (at time of submission).


LINKS

Table of n, a(n) for n=1..22.


EXAMPLE

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 246 triple.


PROG

(PARI) /* This program produces this sequence's elements followed by the elements of A228850 and A228851, and includes asterisks for each billion searched. */
{
\\ The variable a is a parity marker. \\
\\ c is the length of the string. \\
\\ D is the most recent difference. \\
\\ d is the new difference. \\
p=5; q=7; c=2; D=2; a=0; rec=0; z=10^9;
while(1,
d=qp;
if(c>1,
if((a+c)%2,
if(d>D,
c++,
if(c>rec,
rec=c; P=p;
for(i=1, c,
P=precprime(P1));
print1("\n"c": "P", "p));
if(d<D,
c=2; a=1,
c=1)),
if(d<D,
c++,
if(c>rec,
rec=c; P=p;
for(i=1, c,
P=precprime(P1));
print1("\n"c": "P", "p));
if(d>D,
c=2; a=0,
c=1))),
if(d!=D,
c=2;
if(d>D,
a=0,
a=1)));
p=q; q=nextprime(q+1);
if(q>z, z+=10^9; print1("*"));
D=d)
}


CROSSREFS

Cf. A000040, A001223, A036263, A228850, A228851.
Sequence in context: A296300 A224470 A168247 * A186703 A054248 A038108
Adjacent sequences: A229053 A229054 A229055 * A229057 A229058 A229059


KEYWORD

nonn


AUTHOR

James G. Merickel, Sep 16 2013


STATUS

approved



