A058869 Duplicate of A054342.
5, 53, 211, 20201, 16787, 69623, 255803, 247141, 3565979, 6314447, 4911311
Offset: 1
This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
5 belongs to the sequence because 5 = (3 + 7)/2. Likewise 53 = (47 + 59)/2. 5 belongs to the sequence because it is a term, but not first or last, of the AP of consecutive primes (3, 5, 7). 53 belongs to the sequence because it is a term, but not first or last, of the AP of consecutive primes (47, 53, 59). 257 and 263 belong to the sequence because they are terms, but not first or last, of the AP of consecutive primes (251, 257, 263, 269).
a006562 n = a006562_list !! (n-1) a006562_list = filter ((== 1) . a010051) a075540_list -- Reinhard Zumkeller, Jan 20 2012
a006562 n = a006562_list !! (n-1) a006562_list = h a000040_list where h (p:qs@(q:r:ps)) = if 2 * q == (p + r) then q : h qs else h qs -- Reinhard Zumkeller, May 09 2013
[a: n in [1..1000] | IsPrime(a) where a is NthPrime(n)-NthPrime(n+1)+NthPrime(n+2)]; // Vincenzo Librandi, Jun 23 2016
Transpose[ Select[ Partition[ Prime[ Range[1000]], 3, 1], #[[2]] ==(#[[1]] + #[[3]])/2 &]][[2]] p=Prime[Range[1000]]; p[[Flatten[1+Position[Differences[p, 2], 0]]]] Prime[#]&/@SequencePosition[Differences[Prime[Range[800]]],{x_,x_}][[All,2]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jan 31 2019 *)
betwixtpr(n) = { local(c1,c2,x,y); for(x=2,n, c1=c2=0; for(y=prime(x-1)+1,prime(x)-1, if(!isprime(y),c1++); ); for(y=prime(x)+1,prime(x+1)-1, if(!isprime(y),c2++); ); if(c1==c2,print1(prime(x)",")) ) } \\ Cino Hilliard, Jan 25 2005
forprime(p=1,999, p-precprime(n-1)==nextprime(p+1)-p && print1(p",")) \\ M. F. Hasler, Jun 01 2013
is(n)=n-precprime(n-1)==nextprime(n+1)-n && isprime(n) \\ Charles R Greathouse IV, Apr 07 2016
from sympy import nextprime; p, q, r = 2, 3, 5 while q < 6000: if 2*q == p + r: print(q, end = ", ") p, q, r = q, r, nextprime(r) # Ya-Ping Lu, Dec 23 2021
a(2)=47 and it is the lower border of a dd pattern: 47[6 ]53[6 ]59. a(10)=6314393 and a(10)+54=6314447, a(10)+108=6314501 are consecutive primes and 6314393 is the smallest prime prior to a (54,54) difference pattern of A001223.
a = Table[0, {100}]; NextPrime[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; p = q = r = 0; Do[r = NextPrime[r]; If[r + p == 2q && r - q < 201 && a[[(r - q)/2]] == 0, a[[(r - q)/2]] = p]; p = q; q = r, {n, 1, 10^6}]; a (* Typos fixed by Zak Seidov, May 01 2020 *)
list(n)=ve=vector(n);ppp=2;pp=3;forprime(p=5,,d=p-pp;if(pp-ppp==d,i=d\6+1;if(i<=n&&ve[i]==0,ve[i]=ppp;print1(".");vecprod(ve)>0&&return(ve)));ppp=pp;pp=p) \\ Jeppe Stig Nielsen, Apr 17 2022
47, 53 and 59 are primes. There are no other primes between 47 and 59 and 59-53=53-47=6. There are no other such primes with a smaller distance so 53 is included in the sequence.
Primes:= select(isprime,[2,seq(2*i+1,i=1..10^7)]): g:= 0: count:= 0: for i from 2 to nops(Primes)-1 do if Primes[i+1]+Primes[i-1] = 2*Primes[i] and Primes[i+1]-Primes[i] > g then count:= count+1; a[count]:= Primes[i]; g:= Primes[i+1]-Primes[i]; fi od: seq(a[i],i=1..count); # Robert Israel, Sep 20 2015
53 is an equidistant lonely prime. The distance to both the next prime and the previous prime is 6, larger than for any smaller prime. Thus 6 is in the sequence.
a(36)=23346809 because 23346809-72, 23346809 and 23346809+72 are three successive primes and 23346809 is the least such prime.
Prime[Last /@ SequencePosition[ Differences@ Prime@ Range[4 *10^6], {66, 66}]] (* Giovanni Resta, Apr 18 2016 *)
list(lim)=my(v=List(),p=2,q=3); forprime(r=5,nextprime(lim+1), if(q-p==66 && r-q==66, listput(v,q)); p=q;q=r); Vec(v) \\ Charles R Greathouse IV, Apr 18 2016
T(1,1)=5 because 5 is the only prime p whose predecessor and successor primes are p-2 and p+2, respectively (i.e., 3 and 7). T(7,2)=127 because 127 is the smallest prime p whose predecessor and successor primes are p-14 and p+4, respectively (i.e., 113 and 131). T(2,2)=0: the only set of three numbers {p-4, p, p+4} that are all prime is the set {3, 7, 11}, but these are not consecutive primes. (For every set of three integers {m-4, m, m+4}, exactly one of the three is divisible by 3.) Table begins: 5, 7, 31, 0, 139, 199, 0, 1933, ... 11, 0, 23, 401, 0, 467, 113, 0, ... 29, 37, 53, 89, 337, 509, 953, 3643, ... 0, 97, 367, 0, 409, 1201, 0, 1831, ... 149, 0, 251, 701, 0, 797, 293, 0, ... 521, 223, 1543, 479, 631, 211, 2633, 4111, ... 0, 127, 331, 0, 787, 7057, 0, 13381, ... 1949, 0, 3407, 2609, 0, 3659, 1847, 0, ... ... ... ... ... ... ... ... ... ...
balancedPrimes = {};compositeGaps = {}; Do[pPrev = Prime[i];p = Prime[i + 1]; pNext = Prime[i + 2]; If[p == (pPrev + pNext)/2, AppendTo[balancedPrimes, p]; gap1 = p - pPrev - 1; gap2 = pNext - p - 1; AppendTo[compositeGaps, gap1]; AppendTo[compositeGaps, gap2];], {i, 1, 50000}];recurringCounts = Select[Tally[compositeGaps], #[[2]] > 1 &][[All, 1]]; Sort[recurringCounts](* Hilko Koning, Apr 15 2025 *) (* or with balanced primes *) targetGaps = {1, 5, 11, 17, 23, 29, 35, 41, 47}; gapToBalancedPrimes = Association @@ (Rule[#, {}] & /@ targetGaps); Do[pPrev = Prime[i]; p = Prime[i + 1]; pNext = Prime[i + 2]; If[p == (pPrev + pNext)/2, gap1 = p - pPrev - 1; gap2 = pNext - p -1;uniqueGaps = DeleteDuplicates[{gap1, gap2}]; Do[If[KeyExistsQ[gapToBalancedPrimes, gap], gapToBalancedPrimes[gap] = Append[gapToBalancedPrimes[gap], p]], {gap,uniqueGaps}];], {i, 1, 50000}]; gapToBalancedPrimes (* Hilko Koning, Apr 15 2025 *)
Comments