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”).

A228850
a(n) is the smallest prime which starts a record-length of "alternating" consecutive prime gaps.
3
2, 5, 109, 751, 3313, 5807, 13219, 73699, 453703, 500173, 6948787, 8281531, 26331749, 30344651, 259777993, 272281423, 438570997, 859045237, 1037916329, 3321659639, 3984295199, 12252988661
OFFSET
1,1
COMMENTS
Technically, alternation requires more than 2 values of something, so the first term is a convention this sequence and its description (that follows).
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.
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.)
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).
EXAMPLE
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.
MAPLE
Aruns := proc(P)
option remember;
local p, sdiff, i, snew, q, r ;
p := P ;
q := nextprime(p) ;
r := nextprime(q) ;
sdiff := p+r-2*q ;
if sdiff = 0 then
return 1;
else
for i from 1 do
p := q ;
q := r ;
r := nextprime(q) ;
snew := p+r-2*q ;
if snew*sdiff < 0 then
sdiff := snew ;
else
return i ;
end if;
end do:
end if;
end proc:
A228850 := proc()
local r, p, i ;
r := 0 ;
p :=2 ;
for i from 1 do
if Aruns(p) > r then
printf("%d\n", p) ;
r := Aruns(p) ;
end if;
p := nextprime(p) ;
end do:
end proc:
A228850() ; # R. J. Mathar, Oct 10 2013
PROG
(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); }
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
CROSSREFS
Cf. A001223, A228851 (assoc. largest primes), A229056 (record lengths).
Sequence in context: A215572 A023263 A070855 * A041237 A221476 A015172
KEYWORD
nonn
AUTHOR
James G. Merickel, Sep 05 2013
STATUS
approved