A224989 Let p = prime(n). a(n) = number of primes q less than p, such that both p-q+1 and p-q-1 are primes.
0, 0, 0, 1, 2, 1, 3, 2, 4, 3, 2, 3, 4, 3, 5, 4, 5, 3, 3, 6, 5, 6, 6, 6, 3, 7, 5, 5, 6, 9, 4, 8, 3, 7, 7, 5, 6, 5, 7, 6, 8, 8, 9, 5, 10, 9, 12, 8, 6, 8, 9, 13, 10, 12, 9, 8, 12, 9, 7, 14, 9, 10, 8, 13, 9, 9, 11, 10, 6, 13, 12, 11, 8, 9, 17, 9, 12, 6, 11, 14
Offset: 1
Keywords
Examples
For n=3, p=5, there are no primes q(<5) such that both 5-q+1 and 5-q-1 are primes and hence a(3)=0. Also for n=5, p=11, there are a(5)=2 solutions 5,7 since 11-5+1=7, 11-5-1=5 and 11-7+1=5, 11-7-1=3.
Links
- Harvey P. Dale, Table of n, a(n) for n = 1..1000
Programs
-
Mathematica
Table[p = Prime[n]; c = 0; i = 1; While[i < n, p1 = p - Prime[i]; If[PrimeQ[p1 + 1] && PrimeQ[p1 - 1], c = c + 1]; i++]; c, {n, 80}] Table[Count[Prime[p]-Prime[Range[p-1]],?(AllTrue[#+{1,-1},PrimeQ]&)],{p,80}] (* _Harvey P. Dale, Aug 12 2025 *)