Solution (source code)

= Solution

Two applications of <integration by parts> lower the exponent by two. First, the sine boundary term vanishes:
$$
I_n=[x^{2n}\sin x]_0^\pi-2n\int_0^\pi x^{2n-1}\sin x\,dx
=-2n\int_0^\pi x^{2n-1}\sin x\,dx.
$$
For $n\ge1$, integrate the last expression once more:
$$
\int_0^\pi x^{2n-1}\sin x\,dx=[-x^{2n-1}\cos x]_0^\pi
+(2n-1)\int_0^\pi x^{2n-2}\cos x\,dx
=\pi^{2n-1}+(2n-1)I_{n-1}.
$$
Thus the <recurrence relation> is
$$
\boxed{I_n=-2n\pi^{2n-1}-2n(2n-1)I_{n-1},\qquad n\ge1.}
$$
The starting value is $I_0=\int_0^\pi\cos x\,dx=0$. Successive applications give $I_1=-2\pi$ and $I_2=-4\pi^3+24\pi$, followed by
$$
\boxed{I_3=-6\pi^5+120\pi^3-720\pi.}
$$