login
A248701
Smallest prime such that the preceding n prime gaps are increasing and the following n prime gaps are decreasing.
4
3, 7, 359, 7853, 96401, 2812099, 294276293
OFFSET
1,1
EXAMPLE
a(3)=359; [347, 349, 353, 359, 367, 373, 379]; prime gaps [2, 4, 6, 8, 6, 6] which are monotonically increasing 2 <= 4 <= 6 and decreasing 8 >= 6 >=6.
MAPLE
A248701 := proc(n)
local glist, p, wrks, s ;
if n = 0 then
return ;
else
s := n+1 ;
p := ithprime(s) ;
glist := [seq(ithprime(i+1)-ithprime(i), i=1..2*n)] ;
while true do
wrks := true;
for i from 1 to n-1 do
if glist[i] > glist[i+1] then
wrks := false;
break;
end if;
end do:
for i from n+1 to 2*n-1 do
if glist[i] < glist[i+1] then
wrks := false;
break;
end if;
end do:
if wrks then
return p;
end if;
p := nextprime(p) ;
s := s+1 ;
glist := subsop(1=NULL, glist) ;
glist := [op(glist), ithprime(s+n)-ithprime(s+n-1)] ;
end do:
end if;
end proc: # R. J. Mathar, Dec 17 2014
PROG
(PARI) isoka(i, n, vgp) = {for (k=0, n-2, if (vgp[i-k-1] > vgp[i-k], return(0)); if (vgp[i+k+1] < vgp[i+k+2], return(0)); ); return(1); }
a(n) = {nb = 10000; pa = prime(1); pb = prime(nb); vp = primes([pa, pb]); nbp = #vp; vgp = vector(nbp-1, k, vp[k+1] - vp[k]); ok = 0; while (!ok, for (i=1+n, nbp-n-1, if (isoka(i-1, n, vgp), ok = vp[i]; break); ); if (! ok, pa = prime(primepi(pb)-nb+n+1); pb = prime(primepi(pa)+nb); vp = primes([pa, pb]); nbp = #vp; vgp = vector(nbp-1, k, vp[k+1] - vp[k]); ); ); return (ok); } \\ Michel Marcus, Oct 17 2014
CROSSREFS
Sequence in context: A064774 A348376 A089689 * A103317 A104051 A128004
KEYWORD
nonn,more
AUTHOR
Abhiram R Devesh, Oct 12 2014
STATUS
approved