Closed form of sum of function defined on a mod operator

53 Views Asked by At

Given this function defined on $\mathbb{Z}$:

$f(k)=\left\{\begin{array}{c} 1 \text{, if $(\alpha k+\beta$ mod $\gamma) < \alpha$} \\ 0 \text{, otherwise}\end{array} \right\}$

I want to calculate:

$S = \sum_{k=a}^{b} f(k)$

where $a, b \in \mathbb{Z}$ and $b > a$.

It's quite easy to see that $S$ sometimes is the integer part of $(b-a)\frac{\alpha}{\gamma}$ and sometimes is the ceiling part of $(b-a)\frac{\alpha}{\gamma}$.

Is there a way to calculate $S$ precisely and directly? Furthermore, given $\alpha, \gamma, a, b$ how does $S$ depend on $\beta$?

Thanks in advance.