Trigonometric terms for floor function $Q_k(n)$ I'm working on some problems of number theory and somehow I could manage to find a more general formula for some problems. However, I needed to define a function $$Q_k(n) = \text{floor}(\frac n{k}) \text{ As, I'm interested in quotient of (n/k) I named it: Q}$$
$\phi(n, k) = F(Q_k(n),Q_{k-1}(n), .....Q_{2}(n),  k)$
Here, $F$ is another complicated summation function which can be simplified (Using simple algebra)

*

*What is my difficulty;

I wanted a trigonometric expression for $Q_k(n)$
Ex. I could only find $$Q_2(n) = \frac n{2} - \frac {\left[1-(-1)^n\right]}{4} = \color{green}{\frac n{2} - \frac {1-\cos(n\pi)}{4}} = \frac n{2} - \frac {\sin^2{(\frac {n\pi}{2})}}{2}$$
Similarly, I'm looking for $Q_3(n), Q_4(n) \text{, ..... }Q_k(n)$
If possible, the green part is the highly desired thing for me(With no powers to trigonometric functions so that later I can perform summation.)
 A: Expanding on my comment, $\displaystyle\,Q_k(n)=\left\lfloor\frac{n}{k}\right\rfloor=\frac{n - (n \bmod k)}{k}=\frac{n-a_k(n)}{k}\,$ where $\,a_k(n)=n \bmod k\,$ can be thought of as a recurrence defined by $\,a_k(n)=n \,\mid_{\, n=0, 1, \dots, k-1}\,$ and $\,a_k(n)=a_k(n-k)\,$ for $\,n \ge k\,$. The characteristic polynomial of the recurrence is $\,z^k-1\,$, so $\displaystyle\,a_k(n) = \sum_{i=0}^{k-1} c_i \omega_i^n\,$ where $\,\omega_i\,$ are the $\,k^{th}$ roots of unity and $\,c_i\,$ are constants that can be determined from the initial conditions.
However, calculating the actual expression for $\,a_k(n)\,$ is rather laborious. For a shortcut, we can use the following, proved for example here using either complex numbers or trig identities:
$$
\delta_{k,i}(n) = \frac{1}{k} \sum_{j=0}^{k-1} \cos \frac{j\,2(n-i)\pi}{k} =
\begin{cases}
\begin{align}
& 1 && n \equiv i \pmod{k}
\\ & 0 && \text{otherwise }
\end{align}
\end{cases}
$$
Then:
$$
a_k(n) = \sum_{i=1}^{k-1} i\,\delta_{k,i}(n)=\frac{1}{k}\,\sum_{i=1}^{k-1}\left(i\,\sum_{j=0}^{k-1} \cos \frac{j\,2(n-i)\pi}{k}\right) \tag{1}
$$
For example:

*

*$n=2$
$$
\begin{align}
a_2(n) &= \frac{1}{2}\left(1 - cos \,n\pi\right)
\\ &= 0, 1, 0, 1, 0, 1, \dots
\end{align}
$$

*

*$n=3$
$$
\begin{align}
a_3(n) &= \frac{1}{3}\left(1 + \cos\frac{2(n - 1)\pi}{3} + \cos\frac{4(n - 1)\pi}{3}+ 2 \left(1 + \cos \frac{2(n - 2) \pi }{3} + \cos\frac{4(n - 2)\pi}{3}\right) \right)
\\ &= 0, 1, 2, 0, 1, 2, \dots
\end{align}
$$
Substituting $\,a_k(n)\,$ from $\,(1)\,$ back into $\displaystyle\,Q_k(n)=\frac{n-a_k(n)}{k}\,$ gives an explicit form for $\,Q_k(n)\,$ in terms of cosines of multiples of $\,\dfrac{2\pi}{k}\,$.
