login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A248701 Smallest prime such that the preceding n prime gaps are increasing and the following n prime gaps are decreasing. 4

%I #33 Apr 11 2016 08:36:05

%S 3,7,359,7853,96401,2812099,294276293

%N Smallest prime such that the preceding n prime gaps are increasing and the following n prime gaps are decreasing.

%H Abhiram R Devesh, <a href="/A248701/a248701.py.txt">Python Code for Generating the Peak Primes</a>

%e 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.

%p A248701 := proc(n)

%p local glist, p, wrks, s ;

%p if n = 0 then

%p return ;

%p else

%p s := n+1 ;

%p p := ithprime(s) ;

%p glist := [seq(ithprime(i+1)-ithprime(i), i=1..2*n)] ;

%p while true do

%p wrks := true;

%p for i from 1 to n-1 do

%p if glist[i] > glist[i+1] then

%p wrks := false;

%p break;

%p end if;

%p end do:

%p for i from n+1 to 2*n-1 do

%p if glist[i] < glist[i+1] then

%p wrks := false;

%p break;

%p end if;

%p end do:

%p if wrks then

%p return p;

%p end if;

%p p := nextprime(p) ;

%p s := s+1 ;

%p glist := subsop(1=NULL, glist) ;

%p glist := [op(glist), ithprime(s+n)-ithprime(s+n-1)] ;

%p end do:

%p end if;

%p end proc: # _R. J. Mathar_, Dec 17 2014

%o (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);}

%o 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

%Y Cf. A248702 - A248704.

%K nonn,more

%O 1,1

%A _Abhiram R Devesh_, Oct 12 2014

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 14 09:19 EDT 2024. Contains 375921 sequences. (Running on oeis4.)