OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..2000
FORMULA
a(n) = prime(n + 1)^2 - prime(n)^2 - (pi(prime(n + 1)^2) - pi(prime(n)^2)).
EXAMPLE
For n = 1, prime(1) = 2 and prime(2) = 3. So the composite numbers between 2^2 = 4 and 3^2 - 1 = 9 - 1 = 8 are 4, 6, and 8, so a(1) = 3.
MAPLE
f:= proc(n) local p, q;
p:= ithprime(n); q:= nextprime(p);
q^2 - p^2 - numtheory:-pi(q^2)+numtheory:-pi(p^2)
end proc:
map(f, [$1..50]); # Robert Israel, Jun 24 2020
MATHEMATICA
Array[#1 - #2 - (PrimePi@ #1 - PrimePi@ #2) & @@ {Prime[# + 1]^2, Prime[#]^2} &, 47] (* Michael De Vlieger, May 24 2020 *)
PROG
(PARI) forprime(n = 2, 220, s = 0; forcomposite(k = n^2, nextprime(n + 1)^2 - 1, s++); print1(s", "))
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Dimitris Valianatos, May 24 2020
STATUS
approved