How to evaluate an infinite sum involving remainders I've been trying to evaluate the sum
$$\sum_{k=0}^\infty \frac{m^k\bmod n}{m^k}$$
where $m$ and $n$ are positive integers greater than $1$ and $a\bmod b$ is the remainder when $a$ is divided by $b$. This came up in a combinatorics problem I was doing, and I know how to evaluate it given $m$ and $n$ (the numerators repeat, so it ends up just being geometric), but I'm not sure how to evaluate it generally. 
Any ideas?

The numerators must repeat because only finitely many possible remainders exist. Suppose the repeating part starts after the first $K$ terms, so you have
\begin{align}
& \sum_{k=1}^K \frac{m^k\bmod n}{m^k} + \sum_{k=K+1}^\infty \frac{m^k\bmod n}{m^k} \\[10pt]
= {} & \sum_{k=1}^K + \sum_{k=K+1}^{K+R} + \sum_{k=K+R+1}^{K+2R} + \sum_{k=K+2R+1}^{K+3R} + \cdots \\
& \text{where $R$ is the length of the repeating part} \\[10pt]
= {} & \sum_{k=1}^K + \left(\sum_{k=K+1}^{K+R}\right)\left( 1 + \frac 1 {m^R} + \frac 1 {m^{2R}} + \frac 1 {m^{3R}} + \cdots \right) \\[10pt]
= {} & \sum_{k=1}^K + \left(\sum_{k=K+1}^{K+R}\right)\left( \frac 1 {1- \dfrac 1 {m^R}} \right)
\end{align}
