login
a(n) is the smallest prime which starts a record-length of "alternating" consecutive prime gaps.
3

%I #33 Oct 21 2013 10:22:38

%S 2,5,109,751,3313,5807,13219,73699,453703,500173,6948787,8281531,

%T 26331749,30344651,259777993,272281423,438570997,859045237,1037916329,

%U 3321659639,3984295199,12252988661

%N a(n) is the smallest prime which starts a record-length of "alternating" consecutive prime gaps.

%C Technically, alternation requires more than 2 values of something, so the first term is a convention this sequence and its description (that follows).

%C Each prime prime(m) is followed by a sequence of prime gaps A001223(m+k), k>=0. We classify a subsequence of A001223 as "alternating" if consecutive values alternatingly increase and decrease, which means, if the associated subsequence of the second differences A036263 (one term shorter) always switches sign if the index increases by one. The length is the maximum l>=1 such that A036263(m+k)*A036263(m+k+1) <0 for all 0<=k<l-1.

%C These lengths in A036263 starting at A036263(m) are 1, 1, 5, 4, 3, 2, 1, 4, 3, 2, 1, 2, 1, 1, 1, 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, 3, 2, 1, 7, 6,... for m >=1. The record lengths of 1, 5, 7,... occur at indices i= 1, 3, 29,.. indicating primes A000040(m) = 2, 5, 109,... as listed in this sequence. (Records are defined by a sequence of strictly increasing lengths, as usual in the OEIS; repetition of a length that was recorded earlier cannot define a new record.)

%C The associated record lengths in A229056 are one larger than defined above, because they do not measure the length in the second differences (A036263) but the length in the first differences (A001223).

%e a(2) = 5 and A228851(2)=23 indicates the second record is generated by the primes 5, 7, 11, 13, 17, 19 and 23, and also the primes 3 and 29 indirectly, with differences 2 < 4 > 2 < 4 > 2 < 4. The preceding difference of 2 (5-3) is not greater than 2 and the following difference of 6 (29-23) is not smaller than 4.

%p Aruns := proc(P)

%p option remember;

%p local p,sdiff,i,snew,q,r ;

%p p := P ;

%p q := nextprime(p) ;

%p r := nextprime(q) ;

%p sdiff := p+r-2*q ;

%p if sdiff = 0 then

%p return 1;

%p else

%p for i from 1 do

%p p := q ;

%p q := r ;

%p r := nextprime(q) ;

%p snew := p+r-2*q ;

%p if snew*sdiff < 0 then

%p sdiff := snew ;

%p else

%p return i ;

%p end if;

%p end do:

%p end if;

%p end proc:

%p A228850 := proc()

%p local r,p,i ;

%p r := 0 ;

%p p :=2 ;

%p for i from 1 do

%p if Aruns(p) > r then

%p printf("%d\n",p) ;

%p r := Aruns(p) ;

%p end if;

%p p := nextprime(p) ;

%p end do:

%p end proc:

%p A228850() ; # _R. J. Mathar_, Oct 10 2013

%o (PARI) alt(p) = {ok = 1; q = nextprime(p+1); da = q - p; p = q; q = nextprime(p+1); db = q - p; dir = sign(db - da); if (dir == 0, return (0)); nb = 2; while (ok, p = q; q = nextprime(p+1); dc = q - p; if (dir < 0, ok = db < dc, ok = db > dc); if (ok, nb ++); dir = sign(dc - db); db = dc;); return (nb);}

%o lista(nn) = {rec = 0; for (n = 1, nn, new = alt(prime(n)); if (new > rec, rec = new; print1(prime(n), ", "));); } \\ _Michel Marcus_, Sep 21 2013

%Y Cf. A001223, A228851 (assoc. largest primes), A229056 (record lengths).

%K nonn

%O 1,1

%A _James G. Merickel_, Sep 05 2013