Find $a_n:a_{n+1}$ if $a_n=\int_0^{\pi/2}\cos^nx.\cos nx.dx$
Attempt 1 \begin{align} &a_{n+1}=\int_0^{\pi/2}\cos^{n+1}x.\cos(n+1)x.dx\\ &=\frac{\sin (n+1)x}{n+1}.\cos^{n+1}x-(n+1)\int\cos^{n}x.\frac{\sin (n+1)x}{(n+1)}.dx\\ &=\frac{\sin (n+1)x}{n+1}.\cos^{n+1}x-\int\cos^{n}x.{\sin (n+1)x}dx\\ &=\frac{\sin (n+1)x}{n+1}.\cos^{n+1}x-\bigg[\frac{-\cos(n+1)x}{n+1}.\cos^nx\\ &\quad\quad\quad\quad\quad\quad\quad\quad-n\int\cos^{n-1}x.\frac{-\cos(n+1)x}{n+1}.dx\bigg]\\ &=\frac{\sin (n+1)x}{n+1}.\cos^{n+1}x+\frac{\cos(n+1)x}{n+1}.\cos^nx\\ &\quad\quad\quad\quad\quad\quad\quad\quad+\frac{n}{n+1}\int\cos^{n-1}x.\big(\cos nx.\cos x-\sin nx\sin x\big)dx\\ &=\frac{\sin (n+1)x}{n+1}.\cos^{n+1}x+\frac{\cos(n+1)x}{n+1}.\cos^nx\\ &\quad\quad\quad\quad\quad\quad\quad\quad+\frac{n}{n+1}\bigg[\color{red}{\int\cos^nx\cos nxdx}+\int\cos^{n-1}x.\sin x.\sin nx.dx\bigg]\\ &=\frac{\sin (n+1)x}{n+1}.\cos^{n+1}x+\frac{\cos(n+1)x}{n+1}.\cos^nx\\ &\quad\quad\quad\quad\quad\quad\quad\quad+\frac{n}{n+1}\bigg[\color{red}{a_n}+\int\cos^{n-1}x.\sin x.\sin nx.dx\bigg] \end{align}
I don't think it is leading anywhere, is there any trickier way to see the solution ?
Note: The solution given in my reference is $2:1$ and I understand that $$ \int_0^{\pi/2}\sin^nx.dx=\int_0^{\pi/2}\cos^nx.dx=\begin{cases} \dfrac{(n-1)(n-3)....2}{n(n-2)....1}\quad\text{if $n$ is odd}\\ \dfrac{(n-1)(n-3)....1}{n(n-2)....2}\quad\text{if $n$ is even} \end{cases} $$
Thanks @Math1000,
Attempt 2 \begin{align} a_n &= \int_0^{\frac\pi2}\cos^n x\cos nx\ \mathsf dx = \frac{1}{2.2^n} \int_0^{\frac{\pi }{2}} \left(e^{i x}+e^{-i x}\right)^n \left(e^{i n x}+e^{-i n x}\right) \, dx\\ I_1&=\int_0^{\frac{\pi }{2}} \left(e^{i x}+e^{-i x}\right)^n e^{i n x}.dx\\ &=\bigg[(e^{i x}+e^{-i x})^n\frac{e^{inx}}{in}\bigg]_0^{\pi/2}-n\int(e^{i x}+e^{-i x})^{n-1}\frac{e^{i n x}}{in}.dx\\ &=\frac{1}{in}-n\int(e^{i x}+e^{-i x})^{n-1}\frac{e^{i n x}}{in}.dx\\ I_2&=\int_0^{\frac{\pi }{2}} \left(e^{i x}+e^{-i x}\right)^n e^{-i n x}.dx\\ &=\bigg[(e^{i x}+e^{-i x})^n\frac{e^{-inx}}{-in}\bigg]_0^{\pi/2}-n\int(e^{i x}+e^{-i x})^{n-1}\frac{e^{-i n x}}{-inx}.dx\\ &=\frac{-1}{in}+n\int(e^{i x}+e^{-i x})^{n-1}\frac{e^{-i n x}}{in}.dx\\ a_n&=\frac{i}{4}\bigg(\int_0^{\pi/2}(e^{i x}+e^{-i x})^{n-1}e^{i n x}.dx-\int_0^{\pi/2}(e^{i x}+e^{-i x})^{n-1}e^{-i n x}.dx\bigg)\\ &=\frac{i}{2^{n+1}}\int_0^{\pi/2}(e^{i x}+e^{-i x})^{n-1}\Big(e^{i n x}-e^{-i n x}\Big).dx \end{align}