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

A353048
a(n) = (number of primes p in the first n primes such that 2*p+1 is also prime) - (number of primes p in the first n primes such that 2*p-1 is also prime).
1
0, 0, 1, 0, 1, 1, 1, 0, 1, 2, 1, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 3, 2, 2, 2, 2, 2, 3, 3, 4, 4, 3, 3, 3, 2, 2, 2, 3, 4, 4, 5, 5, 5, 4, 3, 3, 3, 2, 3, 4, 4, 5, 5, 5, 5, 4, 4, 5, 5, 6, 5, 5, 5, 5, 4, 3, 3, 3, 3, 4, 3, 3, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 5, 5
OFFSET
1,10
COMMENTS
a(n) is the number of members of A005384 <= prime(n) minus the number of members of A005382 <= prime(n).
LINKS
T. Haddad, Prime Number Races, Université de Montréal master's thesis, 2020.
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
Sequence in context: A205217 A054635 A003137 * A006842 A299038 A273693
KEYWORD
sign
AUTHOR
J. M. Bergot and Robert Israel, Apr 20 2022
STATUS
approved