So according to definition, the fourier series for an even function $f(x)$ is given by
$$f(x)=a_0+\sum_{n\in N}a_n\cos\left(\frac{\pi n x}{L}\right)\tag1$$ where $$a_0=\frac{1}{2L}\int\limits_{-L}^{L}f(x)dx,\tag2$$ $$a_n=\frac{1}{L}\int\limits_{-L}^{L}f(x)\cos\left(\frac{\pi n x}{L}\right)\tag3dx$$
For $f(x)=|\sin(x)|$ we have that $2L=\pi\Leftrightarrow L=\pi/2.$ So
$$a_0=\frac{1}{\pi}\int\limits_{\pi/2}^{-\pi/2}|\sin(x)|dx=\frac{1}{\pi}\int\limits_{0}^{\pi}\sin(x)dx=\frac{2}{\pi}.\tag4$$
Also
$$a_n=\frac{2}{\pi}\int\limits_{0}^{\pi}\sin(x)\cos(nx)dx=\frac{2((-1)^{n+1}-1)}{\pi(n^2-1)}, \quad n\in\mathbb{N}.\tag 5$$
This means that
$$a_n=\left\{ \begin{array}{rcr} 0 & \text{if} & n&=&2k+1 \\ -\frac{4}{\pi(n^2-1)} & \text{if} & n&=&2k \\ \end{array}, \quad k\in\mathbb{N} \right.\tag6$$
So using only the even values of $n$ we get that
$$|\sin(x)|=\frac{\pi}{2}-\frac{4}{\pi}\sum_{k=1}^{\infty}\frac{\cos(2kx)}{4k^2-1}.\tag{7}$$
Keep in mind that these answers are verified to be correct. Obsiously, if I plug in $n=0$ in $(6)$ I should get $a_0=\pi/2$, however when I do this, I get $a_0=\pi/4.$ I don't understand why?