Let $S(n)=\sum_{k=1}^n\text{nmod k}$ the sum of remainder function, denoting $\sigma(n)$ as the sum of divisors function, it is know that for each $n>1$ $$S(n)-S(n-1)=2n-1-\sigma(n),$$ is as curiority an statement due to Lucas. Too it is know the identities that we can show for perfect nubmers, almos perferct numbers and prime numbers. See here. On the other hand it is know some attempts and theorems that look capture the definition of a sequence only in terms of an arithmetic function.
My attempt was use previous function to show that
Fact 1. If $m=2^p-1$ is a Mersenne prime then $$m\left(S\left(m\right)-S\left(m-1\right)\right)+S\left(\frac{m-1}{2}\right)-S\left(\frac{m+1}{2}\right)=m(m-2).$$
$$$$
The proof is show that then $m(m-2)-\left(m-(2^p-1)\right)=m(m-2)$. Notice that the second summand $-\left(m-(2^p-1)\right)$ is zero.
Fact 2. Conversely if $m>3$ is an odd integer and safisties the equation in previous fact, then this satisfies $$m^2+\sigma\left(\frac{m+1}{2}\right)=m\sigma(m),$$ and thus denoting $m=2k-1$ one has $$4k^2+1-4k+\sigma(k)=(2k-1)\sigma(2k-1).$$
$$$$
Computational facts. I don't know if previous identity involving the sum of divisor function for odd integers is in the literature. My computations were that only obtain Mersenne primes when I use a computer. On the other hand as I've said there are relationships between the formulas for primes and almost perfect numbers, for this reason I am confusing. Also I know equation, a relation problem, here in spanish, PROBLEMA 55, page 156-157, where * means unsolved, for which I don't know how clarify this
$$$$
Question. Can you get a closed formula involving only the sum of remainders function, that isn't superfluous, and does capture the definition of Mersenne primes? Is this $$m\left(S\left(m\right)-S\left(m-1\right)\right)+S\left(\frac{m-1}{2}\right)-S\left(\frac{m+1}{2}\right)=m(m-2)?$$ If you can show an odd integer $m$, as counterexample for this last equation I will apprecite, since I don't made computations for this equation. Can you clarify my doubts about if my computations were empty by comparision with the cited literature? Thanks in advance.