From the Wikipedia page on Fourier Series
$\begin{align} \frac{1}{\pi}\int_{-\pi}^{\pi}\frac{\pi}{x}\sin(nx)dx & = -\frac{2}{n \pi}\cos(n \pi) + \frac{2}{n^2 \pi^2}\sin(n \pi) \\ & = \frac{2(-1)^{n+1}}{\pi n} \\ \end{align}$
I understand that the $\sin$ and $\cos$ will alternate between $-1, 0, 1$ but I don't understand the 2nd to 3rd step of simplification. I tried separating out constants but was left with $\cos( n \pi) + \frac{1}{n \pi}\sin(n \pi)$. Any insight?