Calculation of $\int^{\pi/2}_{0}\cos^{n}(x)\cos (nx)\,dx$, where $n\in \mathbb{N}$ 
Compute the definite integral
$$
\int^{\pi/2}_{0}\cos^{n}(x)\cos (nx)\,dx
$$
where $n\in \mathbb{N}$.

My Attempt:
Using $\cos (x) = \frac{e^{ix}+e^{-ix}}{2}$, we get
$$
\begin{align}
\int^{\pi/2}_{0}\cos^{n}(x)\cos (nx)\,dx&=\int_{0}^{\pi/2} \left(\frac{e^{ix}+e^{-ix}}{2}\right)^n\left(\frac{e^{inx}+e^{-inx}}{2}\right)\,dx\\
&= \frac{1}{2^n}\mathrm{Re}\left\{\int_{0}^{\pi/2} \left(e^{ix}+e^{-ix}\right)^n\cdot e^{inx}\,dx\right\}\\
&=\frac{1}{2^n}\mathrm{Re}\left\{\int_{0}^{\pi/2}\left(e^{2ix}+1\right)^n\,dx\right\}
\end{align}
$$
Letting $z=e^{4ix}$ gives us
$$
\begin{align}
e^{4ix}dx &= \frac{1}{4i}dz\\
dx &= \frac{dz}{4iz}
\end{align}
$$
So the integral becomes
$$\frac{1}{4\cdot 2^n}\mathrm{Re}\left\{\int_{C}\left(\sqrt{z}+1\right)\cdot \frac{dz}{iz}\right\}$$
How can I complete the solution from here?

$\newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
$\ds{\int_{0}^{\pi/2}\cos^{n}\pars{x}\cos\pars{nx}\,\dd x:\ {\large ?}.\quad
     n \in {\mathbb N}}$.

With $\ds{0 < \epsilon < 1}$
  $\ds{\pars{~\mbox{we'll take at the end the limit}\ \epsilon \to 0^{+}~}}$:
  \begin{align}&\color{#66f}{\large\int_{0}^{\pi/2}\cos^{n}\pars{x}\cos\pars{nx}
\,\dd x}=\Re
\int_{\verts{z}\ =\ 1\atop{\vphantom{\Huge A}0\ <\ {\rm Arg}\pars{z}\ <\ \pi/2}}
\pars{z^{2} + 1 \over 2z}^{n}z^{n}\,{\dd z \over \ic z}
\\[3mm]&={1 \over 2^{n}}\,\Im
\int_{\verts{z}\ =\ 1\atop{\vphantom{\Huge A}0\ <\ {\rm Arg}\pars{z}\ <\ \pi/2}}
{\pars{z^{2} + 1}^{n} \over z}\,\dd z
=-\,{1 \over 2^{n}}\,\Im\int_{1}^{\epsilon}
{\pars{-y^{2} + 1}^{n} \over \ic y}\,\ic\,\dd y
\\[3mm]&\phantom{=}\left.\mbox{}-{1 \over 2^{n}}\,\Im\int_{\pi/2}^{0}
{\pars{z^{2} + 1}^{n} \over z}\,\dd z\,
\right\vert_{\,z\ =\ \epsilon\expo{\ic\theta}}
-{1 \over 2^{n}}\,\Im\int_{\epsilon}^{1}
{\pars{x^{2} + 1}^{n} \over x}\,\dd x
\\[3mm]&=-\,{1 \over 2^{n}}\Im\int_{\pi/2}^{0}\ic\,\dd\theta
=\color{#66f}{\Large{\pi \over 2^{n + 1}}}
\end{align}

