# About the sum $S(p_n)=\sum_{1\le k\lt n}\,p_n\mod\;p_k$

For $$\,p_n\gt2\,$$ let's define the sum $$\,S(p_n)=\sum_{1\le k\lt n}\,p_n\;mod\;p_k$$, where $$\,p_k\,$$ represents the $$\,k$$-th prime.

The first terms of the sequence $$\,S(p_n)\,$$ (OEIS A033955 - sum of the remainders when the $$\,n$$-th prime is divided by primes up to the $$\,(n-1)$$-th prime) are:

$$S(3)=1\;\;\;(p_2=3)$$

$$S(5)=3\;\;\;(p_3=5)$$

$$S(7)=4\;\;\;(p_4=7)$$

$$S(11)=8\;\;\;(p_5=11)$$

$$S(13)=13\;\;\;(p_6=13)$$

$$S(17)=18\;\;\;(p_7=17)$$

$$S(19)=27\;\;\;(p_8=19)$$

$$S(23)=29\;\;\;(p_9=23)$$

$$S(29)=46\;\;\;(p_{10}=29)$$

The graphical representation of $$\,S(p_n)\,$$ up to $$\,n=1229\,$$ is the following:

The growing of $$\,S(p_n)\,$$ is well estimated by $$S(p_n)\sim n^2\cdot\log\log(n)\;\;\;\;\;\;\;\;(1)$$

Further, the modular equation $$S(p_n)\equiv0\mod p_n\;\;\;\;\;\;\;\;(2)$$ has, up to $$\,n=78498$$, only the following solutions:

$$p_6=13\;\;\;S(13)=13$$

$$p_{39}=167\;\;\;S(167)=1002$$

$$p_{333}=2239\;\;\;S(2239)=123145$$

$$p_{36931}=439867\;\;\;S(439867)=2789196647$$

I ask if the previous results, (1) and (2), can be motivated from a theoretical point of view.

Many thanks.

Others should provide sharper estimates of your $$\ S(p_n)\$$ since I am not any n.th.pro. This is for the starters,
$$S(p_n)\ \ge\ n*p_n - \sum_{p_k\le p_n} p_k \sim \frac 12\cdot n^2\cdot\log(n)$$
$$S(p_n)\ =\ n*p_n\ - \ \sum_m\,\sum_{p_k\le\frac{p_n}m} p_k$$