A377937 Number of primes in the interval [n - A000005(n), n + A000005(n)].
1, 2, 3, 4, 3, 4, 2, 3, 2, 3, 2, 4, 2, 3, 4, 4, 2, 4, 2, 3, 3, 2, 1, 5, 1, 2, 3, 3, 2, 4, 2, 3, 3, 2, 2, 5, 1, 2, 3, 4, 2, 4, 2, 3, 3, 2, 1, 4, 1, 2, 2, 2, 1, 4, 2, 3, 3, 2, 2, 5, 2, 2, 3, 4, 2, 5, 1, 3, 3, 3, 2, 6, 2, 2, 3, 3, 2, 4, 1, 5, 2, 2, 1, 4, 2, 2, 2, 2, 1, 5, 1, 2, 2, 1, 1, 5
Offset: 1
Keywords
Examples
n = 1, there is one prime in [0, 2], thus a(1) = 1. n = 6, there are four primes in [2, 10], thus a(6) = 4.
Programs
-
Mathematica
a[n_] := Module[{d = DivisorSigma[0, n]}, PrimePi[n + d] - PrimePi[n - d - 1]]; Array[a, 100] (* Amiram Eldar, Nov 11 2024 *)
Formula
a(n) = pi(n+tau(n)) - pi(n-tau(n)-1).