Summation over k of Ceiling of mk+x over n

Theorem
Let $m, n \in \Z$ such that $n > 0$.

Let $x \in \R$.

Then:


 * $\ds \sum_{0 \mathop \le k \mathop < n} \ceiling {\dfrac {m k + x} n} = \dfrac {\paren {m + 1} \paren {n - 1} } 2 - \dfrac {d - 1} 2 + d \ceiling {\dfrac x d}$

where:
 * $\ceiling x$ denotes the ceiling of $x$
 * $d$ is the greatest common divisor of $m$ and $n$.