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

Maximal run length of positive primes of the form ..., n-2*3*5, n-2*3, n-2, n, n+2, n+2*3, n+2*3*5, ...
3

%I #17 Aug 22 2021 13:33:00

%S 0,1,2,0,4,0,2,0,0,0,4,0,3,0,0,0,5,0,3,0,0,0,1,0,0,0,0,0,2,0,2,0,0,0,

%T 0,0,1,0,0,0,9,0,4,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,2,0,2,0,0,0,0,0,1,0,

%U 0,0,2,0,4,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,6,0,4,0,0

%N Maximal run length of positive primes of the form ..., n-2*3*5, n-2*3, n-2, n, n+2, n+2*3, n+2*3*5, ...

%H Antti Karttunen, <a href="/A175682/b175682.txt">Table of n, a(n) for n = 1..16384</a>

%H Antti Karttunen, <a href="/A175682/a175682.txt">Data supplement: n, a(n) computed for n = 1..100000</a>

%F a(n) >= A175663(n). - _Antti Karttunen_, Jan 03 2019

%e For n=5, there is a run of primes from 5-A002110(1) to 5+A002110(2): [3, 5, 7, 11] (while 5-A002110(2) = 5-6 = -1 and 5+A002110(3) = 5+30 = 35 are not primes), thus a(5) = 4. - _Antti Karttunen_, Jan 03 2019

%t Array[If[PrimeQ@ #, Block[{s = {1}, t = {1}}, While[PrimeQ[# + Times @@ Prime@ s], AppendTo[s, s[[-1]] + 1]]; While[And[# > 0, PrimeQ[#]] &[# - Times @@ Prime@ t], AppendTo[t, t[[-1]] + 1]]; Last[s] + Last[t] - 1], 0] &, 105] (* _Michael De Vlieger_, Jan 03 2019 *)

%o (PARI) A175682(n) = if(!isprime(n),0,my(pr=2, dn=1, dp=1, rl=1); for(k=1, oo, if(!isprime(n-pr), dn=0); if(!isprime(n+pr), dp=0); if(!(dn+dp), return(rl)); rl += (dn+dp); pr *= prime(1+k))); \\ (Note that isprime in PARI/GP 2.9.4 returns 0 on all negative arguments) - _Antti Karttunen_, Jan 03 2019

%Y Cf. A002110, A175663.

%K nonn

%O 1,3

%A Vladislav-Stepan Malakovsky and _Juri-Stepan Gerasimov_, Aug 08 2010

%E Terms a(5), a(7) and a(19) corrected by _Antti Karttunen_, Jan 03 2019