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

A362663
a(n) is the partial sum of b(n), which is defined to be the difference between the numbers of primes in (n^2, n^2 + n] and in (n^2 - n, n^2].
1
1, 1, 1, 2, 2, 3, 2, 2, 2, 5, 6, 6, 6, 6, 8, 10, 8, 6, 5, 5, 5, 6, 5, 5, 4, 4, 5, 5, 4, 4, 5, 5, 7, 7, 7, 9, 10, 10, 10, 13, 14, 13, 16, 15, 14, 14, 17, 17, 15, 17, 17, 16, 16, 18, 18, 20, 22, 18, 19, 19, 18, 19, 17, 19, 25, 27, 27, 30, 31, 37, 35, 35, 34, 34
OFFSET
1,4
COMMENTS
A plot of a(n) for n up to 100000 is given in Links. First negative term is a(177) = -7 and first zero term appears at n = 198.
FORMULA
a(n) = a(n-1) + primepi(n^2+n) + primepi(n^2-n) - 2*primepi(n^2).
a(n) = Sum_{i=1..n} (primepi(i^2+i) + primepi(i^2-i) - 2*primepi(i^2)).
a(n) = 2 + Sum_{i=2..n} (A089610(i) - A094189(i)), for n >= 2.
a(A192391(m)) = a(A192391(m)-1), for m >= 2.
EXAMPLE
a(1) = primepi(1^2+1) + primepi(1^2-1) - 2*primepi(1^2) = 1+0-2*0 = 1.
a(2) = a(1) + primepi(2^2+2) + primepi(2^2-2) - 2*primepi(2^2) = 1+3+1-2*2 = 1.
a(3) = a(2) + primepi(3^2+3) + primepi(3^2-3) - 2*primepi(3^2) = 1+5+3-2*4 = 1.
a(4) = a(3) + primepi(4^2+4) + primepi(4^2-4) - 2*primepi(4^2) = 1+8+5-2*6 = 2.
PROG
(Python)
from sympy import primerange; a0 = 0; L = []
def ct(m1, m2): return len(list(primerange(m1, m2)))
for n in range(1, 75): s = n*n; a = a0+ct(s, s+n+1)-ct(s-n+1, s); L.append(a); a0 = a
print(*L, sep = ", ")
(PARI) a(n) = sum(i=1, n, primepi(i^2+i) + primepi(i^2-i) - 2*primepi(i^2)); \\ Michel Marcus, May 24 2023
CROSSREFS
KEYWORD
sign
AUTHOR
Ya-Ping Lu, Apr 29 2023
STATUS
approved