%I #50 Jan 02 2024 02:39:43
%S 0,1,3,5,8,11,15,19,23,27,32,37,43,49,55,61,68,75,83,91,99,107,116,
%T 125,134,143,152,161,171,181,192,203,214,225,236,247,259,271,283,295,
%U 308,321,335,349,363,377,392,407,422,437,452,467,483,499,515,531,547,563,580,597,615,633,651,669
%N a(n) = Sum_{k=1..n} pi(k) (cf. A000720).
%C a(n) = A002815(n) - n. - _Reinhard Zumkeller_, Feb 25 2012
%C From _Hieronymus Fischer_, Sep 26 2012: (Start)
%C Let S(n) be a string of length n, then a(n) is the number of substrings of S(n) with a prime number of characters. Example 1: "abcd" is a string of length 4; there are a(4)=5 substrings with a prime number of characters (ab, bc, cd, abc and bcd). Example 2: "abcde" is a string of length 5; there are a(5)=8 substrings with a prime number of characters (ab, bc, cd, de, abc, bcd, cde and abcde).
%C Also: If n is represented in base 1 (this means 1=1_1, 2=11_1, 3=111_1, 4=1111_1, etc.), then a(n) is the number of substrings of n with a prime number of digits. Example: 7=1111111_1; the number of prime substrings of 7 (in base 1) is a(7)=15, since there are 15 substrings of prime length: 6 2-digit substrings, 5 3-digit substrings, 3 5-digit substrings and 1 7-digit substring.
%C (End)
%H Hieronymus Fischer, <a href="/A046992/b046992.txt">Table of n, a(n) for n = 1..10000</a> (first 1000 terms from T. D. Noe)
%F O.g.f.: A(x)/(1-x)^2 where A(x) = Sum_{p=prime} x^p is the o.g.f. of A010051 and A(x)/(1-x) is the o.g.f. of A000720. - _Geoffrey Critzer_, Dec 04 2011
%F From _Hieronymus Fischer_, Sep 26 2012: (Start)
%F a(n) = Sum_{p<=n, p is prime} (n - p +1).
%F a(n) = (n+1)*pi(n) - Sum_pi(n), where pi(n) = number of primes <= n and Sum_pi(n) = sum of primes <= n.
%F a(n) = (n+1)*A000720(n) - A034387(n).
%F (End)
%F a(n) ~ n^2 / (2 log n). - _Charles R Greathouse IV_, Mar 03 2017
%t f[n_] := (f[n - 1] + PrimePi[n]); f[1] = 0; Table[ f[n], {n, 1, 60}]
%t Accumulate[PrimePi[Range[70]]] (* _Harvey P. Dale_, Feb 27 2013 *)
%o (Haskell)
%o a046992 n = a046992_list !! (n-1)
%o a046992_list = scanl1 (+) a000720_list
%o -- _Reinhard Zumkeller_, Feb 25 2012
%o (PARI) a(n)=my(N=n+1,s); forprime(p=2,n, s+=N-p); s \\ _Charles R Greathouse IV_, Mar 03 2017
%o (Python)
%o from sympy import primerange
%o def A046992(n): return (n+1)*len(p:=list(primerange(n+1)))-sum(p) # _Chai Wah Wu_, Jan 01 2024
%Y Cf. A035244, A079397, A213300-A213321.
%K nonn,easy,nice
%O 1,3
%A _N. J. A. Sloane_, _Robert G. Wilson v_
%E Corrected by _Henry Bottomley_