OFFSET
1,10
COMMENTS
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
T. Haddad, Prime Number Races, Université de Montréal master's thesis, 2020.
Robert Israel, Plot of (n, a(n)) for n = 1..10^6
EXAMPLE
Of the first 5 primes there are 4 (2, 3, 5 and 11) such that 2*p+1 is prime and 3 (2, 3 and 7) such that 2*p-1 is prime, so a(5) = 4 - 3 = 1.
MAPLE
f:= proc(p) `if`(isprime(2*p+1), 1, 0) - `if`(isprime(2*p-1), 1, 0) end proc:
L:= map(f, [seq(ithprime(i), i=1..200)]):
ListTools:-PartialSums(L);
MATHEMATICA
Accumulate[(Boole[PrimeQ[2*# + 1]] - Boole[PrimeQ[2*# - 1]]) & /@ Prime[Range[100]]] (* Amiram Eldar, Apr 20 2022 *)
PROG
(Python)
from itertools import accumulate
from sympy import isprime, prime, primerange
def f(p): return isprime(2*p+1) - isprime(2*p-1)
def aupton(nn): return list(accumulate(map(f, primerange(2, prime(nn)+1))))
print(aupton(99)) # Michael S. Branicky, Apr 20 2022
(PARI) a(n) = my(vp=primes(n)); sum(k=1, n, isprime(2*vp[k]+1)-isprime(2*vp[k]-1)); \\ Michel Marcus, Apr 21 2022
CROSSREFS
KEYWORD
sign
AUTHOR
J. M. Bergot and Robert Israel, Apr 20 2022
STATUS
approved