As an amateur mathematician, I have always been fascinated by the magic of prime numbers, and their apparently random distribution. I was utterly amazed when I found the following connection between sums of prime numbers and its distribution:


**Theorem 1**


*Let us define the prime counting function up to a given natural number $n$ as $\pi(n)$, and the sum of consecutive prime numbers up to the integer part of the square root of a given natural number $n$ as $S(n)=\sum\_{p\leq\sqrt{n}}p$. Then, we have that $S(n)\sim\pi(n)$*.


***Proof***


By partial summation $$S(n)=(\left\lfloor \sqrt{n}\right\rfloor \pi(\sqrt{n}))-\sum\_{m=2}^{\left\lfloor \sqrt{n}\right\rfloor -1}\pi(m)$$


Where $\left\lfloor \sqrt{n}\right\rfloor$ denotes the integer part of $\sqrt{n}$.


By the Prime Number Theorem with error term, there exists a constant $C$ such that $$\Big|\pi(x)-\frac{x}{\log x}\Big|\le C\frac{x}{\log^{2}x}\qquad\text{for }x\ge2$$


Therefore, substituting $\pi(\sqrt{n})$ and $\pi(m)$ by the application of the Prime Number Theorem, we get that $$S(n)=(\left\lfloor \sqrt{n}\right\rfloor \frac{\sqrt{n}}{\log(\sqrt{n})})-\sum\_{m=2}^{\left\lfloor \sqrt{n}\right\rfloor -1}\frac{m}{\log(m)}+O\left(\frac{n}{\log^{2}(\sqrt{n})}\right)$$


Applying Riemman Sums theory, we get that $$\sum\_{m=2}^{\left\lfloor \sqrt{n}\right\rfloor -1}\frac{m}{\log(m)}=\int\_{2}^{\left\lfloor \sqrt{n}\right\rfloor }\frac{x}{\log\left(x\right)}dx+O\left(\frac{n}{\log^{2}(\sqrt{n})}\right)$$


Solving the integral by partial integration, we have that


$$\int\_{2}^{\left\lfloor\sqrt{n}\right\rfloor}\frac{x}{\log\left(x\right)}dx=$$


$$=\frac{n}{2\ln\left(\left\lfloor\sqrt{n}\right\rfloor \right)}+O\left(\frac{n}{\log^{2}(\sqrt{n})}\right)$$


It is easy to see that $$\frac{n}{2\log\left(\left\lfloor \sqrt{n}\right\rfloor \right)}\sim\frac{n}{\log n}$$


Thus, $$\sum\_{m=2}^{\left\lfloor \sqrt{n}\right\rfloor -1}\frac{m}{\log(m)}\sim\frac{n}{\log\left(n\right)}+O\left(\frac{n}{\log^{2}(\sqrt{n})}\right)$$


It can be seen that $$\left\lfloor \sqrt{n}\right\rfloor \frac{\sqrt{n}}{\log(\sqrt{n})}\sim\frac{n}{\log\left(\sqrt{n}\right)}=\frac{n}{\frac{1}{2}\log\left(n\right)}=\frac{2n}{\log\left(n\right)}$$


Substituting, we have that $$S(n)\sim\frac{2n}{\log\left(n\right)}-\frac{n}{\log\left(n\right)}+O\left(\frac{n}{\log^{2}(\sqrt{n})}\right)$$


As $$\frac{2n}{\log\left(n\right)}-\frac{n}{\log\left(n\right)}=\frac{n}{\log\left(n\right)}$$


Thus, $$S(n)\sim\frac{n}{\log\left(n\right)}$$


And subsequently, as by the Prime Number Theorem $\pi(n)\sim\frac{n}{\log(n)}$ it can be stated that $S(n)\sim\pi(n)$


After reaching this nice result, I wondered if it could happen that $S(n)=\pi(n)$, and found that the answer was YES. In fact, as I found that there were many cases such that $S(n)=\pi(n)$, I conjectured that this equality occured infinitely often. And thanks to [GH from MO](https://mathoverflow.net/users/11919/gh-from-mo), the conjecture was proven [here](https://mathoverflow.net/questions/383610/set-of-prime-numbers-q-such-that-sum-limits-p-leq-sqrtqp-piq-where) for $n$ being prime, and thus we can state that


**Theorem 2**


*$S(n)=\pi(n)$ infinitely often*


As the prime counting function up to some composite number equals the prime counting function up to the inmediate prior prime number, considering the set $M=\{m\_{1},m\_{2},...,m\_{k}\}$ as the set of values of $n$ such that $\pi\left(n\right)=S\left(n\right)$ and $n$ is some prime number, if $\pi\left(m\_{k}\right)=S\left(m\_{k}\right)$, then, as $\pi\left(m\_{k}\right)=\pi\left(m\_{k}+1\right)=\pi\left(m\_{k}+2\right)=...=\pi\left(m\_{k+1}-1\right)$, it follows that all the composite numbers between $m\_{k}$ and $m\_{k+1}$ are intersection points.


A pending question to be solved is that the first value of $n$ with a concrete $\pi\left(n\right)=S\left(n\right)$ seems to be always a prime number. This conjecture assumes the truth of the following


**Conjecture**. *It does not exist any squared prime number $p\_{k}^{2}$ such that $\pi\left(p\_{k}^{2}\right)=S\left(p\_{k}^{2}\right)$ except of $p\_{1}=2$. That is, $\pi\left(p\_{k}^{2}\right)\neq\sum\_{i=1}^{k}p\_{i}$*


The conjecture has been tested and found to be true for the first thousands of primes. As if $\pi\left(p\_{k}^{2}\right)=S\left(p\_{k}^{2}\right)$ then necessarily $\pi\left(p\_{n}\right)-S\left(p\_{n}\right)=p\_k$, where $p\_n$ is the prime number inmediately lesser than $p\_{k}^2$, one way to prove the conjecture would be to improve the result proved by [GH from MO](https://mathoverflow.net/users/11919/gh-from-mo) $$\pi(x)-S(x)=\Omega\_\pm(x^\frac{1}{2})$$ to $$\pi(x)-S(x)\leq{x^\frac{1}{2}}$$ for all $x\in\mathbb{P}$, or at least for those prime numbers inmediately lesser than $p\_{k}^{2}$.


Now, many further questions regarding the connection between sums of prime numbers and its distribution remain unanswered, and honestly I do not really know how to deepen more on them. Do the two theorems exposed imply that the number of primes between $p\_{n}^{2}$ and $p\_{n+1}^{2}$ , on average, do not differ much from $p\_{n+1}$? Does this connection add any new insight on the distribution of prime numbers, and it is worthy to be studied and exploited further to know more about the distribution of prime numbers? Is the result $$\pi(x)-S(x)\leq{x^\frac{1}{2}}$$ for all $x\in\mathbb{P}$, or at least for those prime numbers $p\_n$ inmediately lesser than $p\_{k}^{2}$ provable? Does it exist some counterexample?


I would appreciate your comments and ideas. Thanks in advance!



On the connection between sums of prime numbers and distribution of prime numbers
The [post that you quoted](https://mathoverflow.net/questions/383610/set-of-prime-numbers-q-such-that-sum-limits-p-leq-sqrtqp-piq-where) contains a proof that
$$\pi(x)-S(x)=\Omega\_\pm(x^c)\quad\text{for any}\quad c<3/4.$$
Equivalently, for any $c<3/4$ and any $C>0$, both $\pi(x)-S(x)\leq Cx^c$ and $\pi(x)-S(x)\geq -Cx^c$ are false.


