OFFSET
1,2
LINKS
Chris K. Caldwell, How Many Primes Are There?
Xavier Gourdon & Pascal Sebah, Counting the number of primes
Henri Lifchitz, Parity of Pi(n)
Thomas R. Nicely, Some Results of Computational Research in Prime Numbers [See local copy in A007053]
Tomás Oliveira e Silva, Tables of values of pi(x) and of pi2(x)
FORMULA
a(n) = Sum_{k=0..n-1} pi(2*10^k-1) - pi(10^k-1). - Andrew Howroyd, Dec 15 2024
EXAMPLE
a(2)=4 because there are 4 primes up to 10^2 whose initial digit is 1 (11, 13, 17 and 19).
MATHEMATICA
f[n_] := f[n] = PrimePi[2*10^n] - PrimePi[10^n] + f[n - 1]; f[0] = 0; Table[ f[n], {n, 0, 13}]
PROG
(PARI) a(n, d=1)=sum(k=0, n-1, primepi((d+1)*10^k-1) - primepi(d*10^k-1)) \\ Andrew Howroyd, Dec 15 2024
CROSSREFS
KEYWORD
base,hard,nonn,changed
AUTHOR
Shyam Sunder Gupta, Aug 14 2002
EXTENSIONS
Edited and extended by Robert G. Wilson v, Aug 29 2002
a(21)-a(22) added by David Baugh, Mar 21 2015
a(23) from Chai Wah Wu, Sep 18 2018
Offset corrected by Andrew Howroyd, Dec 15 2024
STATUS
approved