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.
LINKS
FORMULA
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