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.

Here is the final answer by maple

$$ 2\,{\frac {2\, \left( -1 \right) ^{k} \left( \cos \left( \pi \,kn
 \right)  \right) ^{2}-2\, \left( \cos \left( \pi \,kn \right) 
 \right) ^{2}+ \left( -1 \right) ^{k+1}+1}{{k}^{2}}}
. $$

Added: More simplification leads to the more compact form

$$ 2\,{\frac {\cos \left( 2\,\pi \,kn \right)  \left(  \left( -1 \right) 
^{k}-1 \right) }{{k}^{2}}}.$$

