How do I calculate $$ S(n,m) = \sum_{i = 1}^{n} \Bigl \lfloor \frac{n}{i^m} \Bigr \rfloor i^m $$ This can be simplifies to
$$ S(n, m) = \sum_{i = 1}^{\sqrt[m] n} \Bigl \lfloor \frac{n}{i^m} \Bigr \rfloor i^m = \sum_{i = 1}^{\sqrt[m] n} n - \sum_{i = 1}^{\sqrt[m] n}n \bmod i^m$$
Example
$$S(100,2) = \sum_{i=1}^{10} \Bigl \lfloor \frac{n}{i^2} \Bigr \rfloor i^2 = 100 + 100 + 99 + 96 + 100 + 72 + 98 + 64 + 81 + 100 = 910$$
More work.
Let's divide the $\Bigl \lfloor \frac{n}{i^{2}} \Bigr \rfloor $ into intervals of $1, 2, 3, \cdots$ Like this. and calculate the sum.
i.e from interval $\sqrt{\frac{n}{1}} \ge i \gt \sqrt{\frac{n}{2}} \quad $ like this and the summation becoms.
$$S(n,2) = \sum_{1}^{\bigl \lfloor \frac{n}{2} \bigr \rfloor} \Bigl \lfloor \frac{n}{i^2} \Bigr \rfloor i^2 + \sum_{i = \bigl \lfloor \frac{n}{2} \bigr \rfloor}^{\lfloor n \rfloor} 1 . i^2 $$
like so we can divide it even more but nothing converges to a smaller value and the multiplier of $i^2$ keeps on increasing.
$$S(n,2) = \sum_{i = \bigl \lfloor \frac{n}{2} \bigr \rfloor}^{\lfloor n \rfloor} 1 . i^2 + \sum_{i = \bigl \lfloor \frac{n}{3} \bigr \rfloor}^{\bigl \lfloor \frac{n}{2} \bigr \rfloor} 2 . i^2 + \sum_{i = \bigl \lfloor \frac{n}{4} \bigr \rfloor}^{\bigl \lfloor \frac{n}{3} \bigr \rfloor} 3 . i^2 + \cdots$$
Is there a way to generalize this?
Hint
Using the division algorithm, we can write $a=kq+r$, where $0 \leq r < k$. Then, $$\frac{a}{k}=q+\frac{r}{k} \implies q=\lfloor\frac{a}{k}\rfloor.$$ So $$a=k\lfloor\frac{a}{k}\rfloor+r \implies \lfloor\frac{a}{k}\rfloor k=a-r.$$