Help to compute the following coefficient in Fourier series $\int_{(2n-1)\pi}^{(2n+1)\pi}\left|x-2n\pi\right|\cos(k x)\mathrm dx$ 
$$\int_{(2n-1)\pi}^{(2n+1)\pi}\left|x-2n\pi\right|\cos(k x)\mathrm dx$$
  where $k\geq 0$, $k\in\mathbb{N} $ and $n\in\mathbb{R} $.

it is a $a_k$ coefficient in a Fourier series.

Changing the variable as Mercy did $x-2n\pi=t$
$$\int_{(2n-1)\pi}^{(2n+1)\pi}\left|x-2n\pi\right|\cos(k x)\mathrm dx=\int_{-\pi}^{\pi}|t|
\cos(kt+2kn\pi)\,dt$$
Then expanding cosine one can obtain:
$$\cos(2kn\pi)\int_{-\pi}^{\pi}|t|\cos(kt)\,dt-\sin(2kn\pi)\int_{-\pi}^{\pi}|t|\sin(kt)\,dt$$
Noting that $|t|\cos(kt)$ is even and $|t|\sin(kt)$ is odd and using the fact that on a symmetric interval the integral of the odd function is zero and the integral of the even function is equal to the doubled integral on the halved interval one can get:
$$\int_{-\pi}^{\pi}|t|
\cos(kt+2kn\pi)\,dt=2\cos(2kn\pi)\int_{0}^{\pi}t\cos(kt)\,dt=\frac{2 \left((-1)^k-1\right) (\cos  (2 \pi  k n))}{k^2}$$
