How can the integral $\int_0^\frac{\pi}{2} x \cos ^n{x} dx$ be reduced? I tried to write $cos^nx$ as $\cos {x} \cos ^{n-1}{x}$ and then integrate by parts with the first function being $\cos ^{n-1}{x}$ and the second function being $x  \cos {x}$. I was able to solve upto a point but then I got stuck since I was not able to find a term which I could write as $I_{n-k}$ assuming that the integral in the title is $I_n$ and $k$ is any integer less than $n$. Am I taking incorrect functions to solve by parts or do I need to do any trigonometric manipulation using the limits of the integral?

To get a recurrence for the given integral, call it $I_n$, observe that $$I_{n-2}-I_n=\int_0^{\pi/2}x\cos^{n-2}x\sin^2 x\,dx=\int_0^{\pi/2}(x\sin x)(\cos^{n-2}x\sin x)\,dx,$$ which is ready to be integrated by parts: $$I_{n-2}-I_n=\frac{1}{n-1}\int_0^{\pi/2}\cos^{n-1}x(\sin x+x\cos x)\,dx=\frac{1}{n-1}\left(\frac{1}{n}+I_{n}\right),$$ yielding $I_n=\left(1-\frac{1}{n}\right)I_{n-2}-\frac{1}{n^2}$.
