What is the sum of the prime numbers up to a prime number $n$? [duplicate]

How to find the sum of prime numbers up to a prime number $n$, that is for example: the sum of prime numbers up to 7 is: 2+3+5+7=17.

So what is the formula for finding: $$\sum_{k=0}^n p_k=????,$$ with $p_k$ being the $k$th prime.

Also if we have the sum of an even number of primes then would it be a new prime? Example: 2+3+5+7=17 and 17 is a prime. 2+3+5+7+11+13=41 and 41 is prime.

Thank you.


Solution 1:

In this answer, I use partial summation to show that

Asymptotic: For $k>-1$ we have $$\sum_{p\leq x}p^{k}=\text{li}\left(x^{k+1}\right)+O\left(x^{k+1}e^{-c\sqrt{\log x}}\right).$$

Where $\text{li}(x)=\int_2^x \frac{1}{\log t}dt$ is the logarithmic integral. Letting $k=1$, we see that $$\sum_{p\leq x } \text{li}\left(x^{2}\right)+O\left(x^{2}e^{-c\sqrt{\log x}}\right),$$ which implies that $$\sum_{p\leq x} p \sim \frac{x^2}{2\log x}.$$ The sum of the first $n$ primes is not as natural to work with. By using the fact that $p_n\sim n\log n$, along with the above asymptotic, it follows that $$\sum_{k=1}^n p_k \sim \frac{1}{2}n^2 \log n.$$ However the next few terms in the asymptotic expansion are not particularly pretty.

Solution 2:

$$ \sum_{p\le x}p = \frac{x^2}{2\log x} + \frac{x^2}{2\log^2x} + \frac{x^2}{4\log^3x} + \frac{3x^2}{8\log^4x} + O\left(\frac{x}{\log^5x}\right). $$