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, the conjecture was proven here 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 he 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 $$\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!