Surprising fact about a certain number-theoretic function Ante suggested the following function :
For natural number $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$
Because of the familiar division-with-remainder-theorem we have $0 \leq b_k <n$
Now we can study the sum $$r(n)=\sum_{k=1}^{\lfloor \frac{n-1}{2} \rfloor}b_k$$
After playing around with some values with support of Haran and Ante, we noticed that $$r(b)=r(b+1)$$ seems to hold if and only if $b+1$ is a power of $2$ or $3$ , including $2$ and $3$
There is no counterexmple upto $10^4$
? r={(p)->su=0;for(j=2,(p-1)/2,su=su+lift(Mod(p,j)));su}
%94 = (p)->su=0;for(j=2,(p-1)/2,su=su+lift(Mod(p,j)));su
? for(j=1,10^4,if(r(j)==r(j+1),print(j," ",factor(j+1))))
1 Mat([2, 1])
2 Mat([3, 1])
3 Mat([2, 2])
7 Mat([2, 3])
8 Mat([3, 2])
15 Mat([2, 4])
26 Mat([3, 3])
31 Mat([2, 5])
63 Mat([2, 6])
80 Mat([3, 4])
127 Mat([2, 7])
242 Mat([3, 5])
255 Mat([2, 8])
511 Mat([2, 9])
728 Mat([3, 6])
1023 Mat([2, 10])
2047 Mat([2, 11])
2186 Mat([3, 7])
4095 Mat([2, 12])
6560 Mat([3, 8])
8191 Mat([2, 13])
? 


Is this in fact true, and if yes, why ?


We have:
$$r(b)=r(b+1)$$
$$\sum_{k=1}^{\lfloor \frac{b-1}{2} \rfloor} (b \bmod{k}) =\sum_{k=1}^{\lfloor \frac{b}{2} \rfloor} ((b+1) \bmod{k}) $$
since $n \equiv b_k \pmod{k}$. Now, we take two cases:
Case $1$ : When $b$ is odd
We have:
$$\sum_{k=1}^{\frac{b-1}{2}} (b \bmod{k}) =\sum_{k=1}^{\frac{b-1}{2}} ((b+1) \bmod{k})$$
$$\sum_{k=1}^{\frac{b-1}{2}} \bigg((b \bmod{k})-((b+1) \bmod{k})\bigg)=0$$
We can see that:
$$ (b \bmod{k})-((b+1) \bmod{k}) =
\begin{cases}
-1  & \text{if $k \nmid (b+1)$} \\
k-1 & \text{if $k \mid (b+1)$}
\end{cases}$$
Essentially, we are to substitute $-1$ for all the values $1 \leqslant k \leqslant \frac{b-1}{2}$ and add $k$ when it is a divisor of $b+1$. $k$ will be all the divisors of $b+1$ excpet $b+1$ and $\frac{b+1}{2}$ since $k \leqslant \frac{b-1}{2}$. We have:
$$\sum_{k=1}^{\frac{b-1}{2}} \bigg((b \bmod{k})-((b+1) \bmod{k})\bigg)=\bigg( \sum_{k=1}^{\frac{b-1}{2}} (-1) \bigg) + \sigma(b+1)-(b+1)-\bigg(\frac{b+1}{2}\bigg)$$
$$ \implies -\bigg(\frac{b-1}{2}\bigg)+\sigma(b+1)-(b+1)-\bigg(\frac{b+1}{2}\bigg)=0 \implies \sigma(b+1)=2b+1$$
Since $b+1$ is even, we have $b+1=x$ for all even $x$ satisfying:
$$\sigma(x)=2x-1$$
Clearly, $x=2^k$ works for all non-negative integers $k$. Such $x$ are known as 'almost perfect numbers'. It is unknown whether powers of $2$ are the only such solutions. For your claim to be true, we need all even almost perfect numbers to be powers of $2$.
Case $2$ : When $b$ is even
This works similarly:
$$\sum_{k=1}^{\frac{b}{2}-1} (b \bmod{k}) =\sum_{k=1}^{\frac{b}{2}} ((b+1) \bmod{k})$$
We can easily see that since $\frac{b}{2} \mid b$, we have $\sum_{k=1}^{\frac{b}{2}-1} (b \bmod{k})=\sum_{k=1}^{\frac{b}{2}} (b \bmod{k})$. Now, we have:
$$\sum_{k=1}^{\frac{b}{2}} (b \bmod{k}) =\sum_{k=1}^{\frac{b}{2}} ((b+1) \bmod{k})$$
$$\sum_{k=1}^{\frac{b}{2}} \bigg((b \bmod{k})-((b+1) \bmod{k})\bigg)=0$$
Using the same logic as in the first case (but we are only to exclude the divisor $b+1$):
$$\sum_{k=1}^{\frac{b}{2}} \bigg((b \bmod{k})-((b+1) \bmod{k})\bigg) = \bigg( \sum_{k=1}^{\frac{b}{2}} (-1) \bigg)+\sigma(b+1)-(b+1)=0$$
$$\sigma(b+1)=\frac{3b+2}{2}$$
We have $b+1=x$ for all odd $x$ satisfying:
$$\sigma(x)=\frac{3x-1}{2}$$
It is clear that $x=3^k$ works for all powers of $3$. However, I doubt it is possible to prove whether these are the only odd solutions, with elementary methods. I wasn't able to find any literature on this subject.
Link:
Almost Perfect Numbers : https://mathworld.wolfram.com/AlmostPerfectNumber.html
