Fourier series, find $a_n$ of $\sin x$, $x \in [0,\pi]$
I tried to solve it myself, and then I got stucked with $\cos(\pi+\pi n)$ there, I uploaded an image of the solution, I didn't understand the part in red.
Lemma: For any integer $k$, $\cos k\pi = (-1)^k$.
Nonproof: This isn't a formal proof but from the below chart we can clearly see a pattern forming.
\begin{array}{c|c} k & \cos k\pi\\ \hline 0 & \cos 0 = 1 = (-1)^0\\ 1 & \cos \pi = -1 = (-1)^1\\ 2 & \cos 2\pi = 1 = (-1)^2\\ 3 & \cos 3\pi = -1 = (-1)^3\\ 4 & \cos 4\pi = 1 = (-1)^4 \end{array} And so on. And this pattern holds for $k < 0$ as well.
Using this, you can say $\cos(n+1)\pi = (-1)^{n+1}$, etc. I haven't worked it out completely but I think it may also be beneficial to note that $(-1)^{n+1} = (-1)^{n-1}$ because $n+1$ and $n-1$ have the same parity.
Let me know if you require further guidance.