  In this paper we characterize, in terms of the prime divisors of $n$, the
pairs $(k,n)$ for which $n$ divides $\sum_{j=1}^n j^{k}$. As an application, we
study the sets $\mathcal{M}_f :=\{n: n \textrm{divides} \sum_{j=1}^n j^{f(n)}
\}$ for some choices of $f$.
