I tried to write $\cos^nx$ as $\cos {x} \cos ^{n-1}{x}$ and then integrating 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 $I_n$ is
$$\int_0^\frac{\pi}{2} x \cos ^n{x} dx$$
and $k\in\mathbb Z, k<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?