A number-13 phenomenon For $n \in \mathbb N$ we can observe the $n$ remainders $b_1,...,b_n$ by writing $n$ as $n=a_k \cdot k+b_k$ for $1 \leq k \leq n$.
The function $$r(n)=\sum_{k=1}^{\lfloor{\frac {n-1}{2}}\rfloor}b_k$$ can be defined.
After doing a research of the function $d(n)=|r(n)-r(n-1)|$ me and Peter arrived at the amazing data:
For $n$ in the range from $1$ to $1000000$ the number $13$ occurs as the value of the function $d$ a striking $15239$ times.
For $n$ in the range from $1$ to $10000000$ the number $13$ occurs as the value of the function $d$ a striking $125813$ times.
From all the other primes that occur as repeating-values of this simple function the number $13$ stands so much in front of them all with such a high number of repetitions that this seems to be amazing.
Can someone tell us more about why this happens? Does someone has even a slightest idea how can this be possible?
 A: Consider $n=6p$ for prime $p>3$. We have:
$$r(n)-r(n-1)=2n-1-\sigma(n)=12p-1-\sigma(6p)$$
We can easily find:
$$\sigma(6p)=(2+1)(3+1)(p+1)=12p+12$$
This gives:
$$r(n)-r(n-1)=12p-1-12p-12=-13$$
Thus, $n$ satisfies our equation. Peter used programming to show that the number of solutions with $n \leqslant 10000$ satisfying $r(n)-r(n-1)=-13$ is $262$. We can see that there are $259$ primes $>3$ that $p$ can take since $p<1667$. This justifies the property!
A: Expanding on Haran's answer, one might ask why $6$ works. For example,
$$r(8p) - r(8p-1) = 16p-1-(1+2+4+8)(1+p) = 16p-1-15(1+p)$$
is not a constant.
This is because $6$ is a perfect number.
Let $n$ be an even perfect number (winks) and $p \nmid n$. Then:
$$r(np) - r(np-1) = 2np-1 - \sigma(np) = 2np-1-\sigma(n)\sigma(p) = 2np-1 - 2n(1+p) = -1-2n$$
So $d(np) = 2n+1$, and this is independent of $p$ precisely because $\sigma(n) = 2n$ because $n$ is a perfect number.
This means, for example, that $2 \times 28 + 1 = 57$ should also be frequent (but not as frequent as $13$), since $28$ is a perfect number.
