Trying to solve a problem I reached a point where I know that $$\sum_{n=1}^{\infty} a_nsin(nx) = f(x) \text{, where }f(x) = \begin{cases} x & 0 \leq x \leq \frac\pi2 \\[5pt] \pi - x & \frac\pi2 < x \leq \pi \end{cases}$$
To solve the problem I need to find a sequence $a_n$. I thought that if I were to find the Fourier series for $f(x)$ that might be it, but I found that the Fourier series is $f(x) = \frac{\pi}{4}-\frac{2}{\pi}\sum_{n=1}^{\infty}\frac{cos((4n-2)x)}{(2n-1)^2}$. The two are not alike at all, and I don't know any other way of finding $a_n$. How should I approach this problem? Is it even possible?
Hint: exend $f$ to $[-\pi,0]$ by defining $f(-x)=-f(x)$. This will result an odd function on $[-\pi, \pi]$, which will have only $\sin$ terms in the Fourier-series (it's called Fourier Sine Series).