Let $p\_n$ be the n-th prime number and $c\_n$ be the n-th composite number. We have 


$$
\lim\_{n \to \infty}\frac{1}{n} \sum\_{r=1}^{n}\frac{p\_n^2}{p\_n^2 + p\_r^2}
= \lim\_{n \to \infty}\frac{1}{n} \sum\_{r=1}^{n}\frac{c\_n^2}{c\_n^2 + c\_r^2} = \frac{\pi}{4}.
$$


The beauty of the above result is that the first limit is a series over prime and the other is a series over composites. Similar results hold if the sequence of primes (or composites) are replaced by the sequence of natural number. This is a specific example of a general family of results of this kind. 


The question is understand why such a relationships hold. I have been working on this and wanted to share with and learn from other number theorists. Has anyone seen similar results in mathematics literature? Any reference would be helpful. 



On prime numbers
The sums above are Riemann sums over different partitions for the function $\arctan(x)$ between $x=0$ and $x=1$, so the limit will equal the integral which is $\frac{\pi}{4}$. Both of these converge to the same value because they are not too weirdly distributed among $[0,1]$.


**Remark:** We need to use the fact that there exists $\theta<1$ with $p\_n-p\_{n-1}\ll p\_n^\theta$. (we can take $\theta=7/12$) For the primes, we know that this tells us that if $j\geq n^{7/12+\epsilon}$, then
$$p\_{n+j}-p\_{n}\sim j\log n. $$


**Edit:** I added why $p\_{n+j}-p\_{n}\sim j n^{7/12}$ for $j\geq n^{7/12+\epsilon}$ is important after reading some of the comments. It tells us/(or actually comes from) how things will look in short intervals for primes. It is not true that for general sequences with $\alpha\_{i}-\alpha\_{i-1}\ll n^{-\delta}$ the Riemann sum works out, rather for sequences where sums over short intervals is very close to the identity function. 


**Edit 2:** This is more of a remark because I have a feeling someone will wonder about this. The reason why we need it to be close to the identity on short intervals is because we are weighting with the identity, $\frac{1}{n}$, rather then $x\_i-x\_{i-1}$ which is what is used in the definition of the Riemann integral. Summation tricks to move to these short intervals allows us to make the desired conclusion. Note that the limit will hold for any bounded monotonic integrable $f$, and any sequence satisfying the condition. 


