A034387 Sum of primes <= n.
0, 2, 5, 5, 10, 10, 17, 17, 17, 17, 28, 28, 41, 41, 41, 41, 58, 58, 77, 77, 77, 77, 100, 100, 100, 100, 100, 100, 129, 129, 160, 160, 160, 160, 160, 160, 197, 197, 197, 197, 238, 238, 281, 281, 281, 281, 328, 328, 328, 328, 328, 328, 381, 381, 381, 381, 381
Offset: 1
Links
- T. D. Noe, Table of n, a(n) for n = 1..10000
- Jens Askgaard, On the additive period length of the Sprague-Grundy function of certain Nim-like games, arXiv:1902.06299 [math.CO], 2019. See p. 25.
- Cino Hilliard, Sum of primes
- Matt Visser, On the arithmetic average of the first n primes, arXiv:2505.04951 [math.NT], 2025. See p. 3.
Crossrefs
Programs
-
Haskell
a034387 n = a034387_list !! (n-1) a034387_list = scanl1 (+) a061397_list -- Reinhard Zumkeller, Mar 21 2014
-
Maple
a:= proc(n) option remember; `if`(n<1, 0, a(n-1)+`if`(isprime(n), n, 0)) end: seq(a(n), n=1..60); # Alois P. Heinz, Jun 29 2022
-
Mathematica
s=0; Table[s=s+n*Boole[PrimeQ[n]],{n,100}] (* Zak Seidov, Apr 11 2011 *) Accumulate[Table[If[PrimeQ[n],n,0],{n,60}]] (* Harvey P. Dale, Jul 25 2016 *)
-
PARI
a(n)=sum(i=1,primepi(n),prime(i)) \\ Michael B. Porter, Sep 22 2009
-
PARI
a=0;for(k=1,100,print1(a=a+k*isprime(k),", ")) \\ Zak Seidov, Apr 11 2011
-
PARI
a(n) = if(n <= 1, return(0)); my(r=sqrtint(n)); my(V=vector(r, k, n\k)); my(L=n\r-1); V=concat(V, vector(L, k, L-k+1)); my(T=vector(#V, k, V[k]*(V[k]+1)\2)); my(S=Map(matrix(#V,2,x,y,if(y==1,V[x],T[x])))); forprime(p=2, r, my(sp=mapget(S,p-1), p2=p*p); for(k=1, #V, if(V[k] < p2, break); mapput(S, V[k], mapget(S,V[k]) - p*(mapget(S,V[k]\p) - sp)))); mapget(S,n)-1; \\ Daniel Suteu, Jun 29 2022
-
Python
from sympy import isprime from itertools import accumulate def alist(n): return list(accumulate(k*isprime(k) for k in range(1, n+1))) print(alist(57)) # Michael S. Branicky, Sep 18 2021
Formula
From the prime number theorem a(n) has the asymptotic expression: a(n) ~ n^2 / (2 log n). - Dan Fux (dan.fux(AT)OpenGaia.com), Apr 07 2001
a(n) = A158662(n) - 1. a(p) - a(p-1) = p, for p = primes (A000040), a(c) - a(c-1) = 0, for c = composite numbers (A002808). - Jaroslav Krizek, Mar 23 2009
a(n) = n^2/(2 log n) + O(n^2 log log n/log^2 n). - Vladimir Shevelev and Charles R Greathouse IV, May 29 2014
Conjecture: G.f.: Sum_{i>0} Sum_{j>=i} Sum_{k>=j|i-j+k is prime} x^k. - Benedict W. J. Irwin, Mar 31 2017
a(n) = Sum_{p<=n, p prime} p. - Wesley Ivan Hurt, Dec 31 2023
Comments