Integrating integer powers of $\cos(\theta)$ Consider the following integral for $n\in\mathbb{N}$:
$$I_n = \int_0^\pi\cos^n\theta\,d\theta \tag1$$
which, using integration by parts, one can show to be $I_n = 0$ for $n$ odd and to be equal to 
$$I_{2m} = \frac{(2m-1)!!}{(2m)!!}\pi \tag2$$
for $n = 2m$ even.
However, I've tried to evaluate $(1)$ using the binomial theorem to write powers of cosine as a sum over powers of exponential functions:
\begin{align}
I_n &= \frac{1}{2^n}\int_0^\pi\left(e^{i\theta}+e^{-i\theta}\right)^n\,d\theta\\
&=\frac{1}{2^n}\sum_{k=0}^n{n\choose k}\int_0^\pi e^{ik\theta}e^{-i(n-k)\theta}\,d\theta\\
&=\frac{1}{2^n}\sum_{k=0}^n{n\choose k}\int_0^\pi e^{i(2k-n)\theta}\,d\theta\\
&=\frac{1}{2^n}\sum_{k=0}^n{n\choose k}\frac{e^{i\pi(2k-n)}-1}{i(2k-n)}
\end{align}
However, this result seems to contradict $(2)$ - note that if $n = 2m$ is even, then $2k-2m$ is an even integer and $e^{2\pi i(k-m)} = 0$ for any value of $k$, which would imply that $I_n$ is nonzero only for odd values of $n$.
Furthermore, if $n = 2m -1$, then we have $e^{i\pi(2k-2m+1)} = -1$ and we thus have
\begin{align}
I_{2m-1} &= \frac{1}{2^{2m-1}}\sum_{k=0}^{2m-1}{{2m-1}\choose k}\frac{-2}{i(2k-2m-1)}\\
&=\frac{i}{2^{2m}}\sum_{k=0}^{2m-1}{{2m-1}\choose k}\frac{1}{2(k-m)-1} \tag3
\end{align}
which is purely imaginary, which is obviously wrong.
So what's the problem here? Am I somehow wrong in using the binomial theorem? Have I made a computational error that explains this odd result? Can this approach to computing $(1)$ be salvaged?
EDIT.
Taking into consideration that the sum is actually non-zero if the argument of the exponential function is itself zero, which occurs if, for $n$ = $2m$, we have $k = m$, this gives us:
\begin{align}
I_{2m} &= \frac{1}{2^{2m}}{{2m}\choose m}\pi = \frac{(2m)!}{2^{2m+1}m!}\pi
\end{align}
However, I don't see how this is equal to $(2)$.
I have also tried to show that $(3)$ is $0$, by symmetry, but I have no managed to show this yet either.
 A: First, note that we have
$$\int_0^\pi e^{i(2k-n)x}\,dx=\begin{cases}\pi&,n=2k\\\\\frac{1-(-1)^n}{i(n-2k)}&,n\ne 2k\end{cases}$$

Now, if $n$ is even, say $n=2m$, then we can write
$$\begin{align}
\int_0^\pi \cos^{2m}(x)\,dx&=\frac{1}{2^{2m}}\sum_{k=0}^{2m}\binom{2m}{k}\pi \delta_{m,k}\\\\
&= \frac{\pi}{2^{2m}}\binom{2m}{m}\\\\
&=\frac{\pi}{2^{2m}} \frac{(2m)!}{(m!)^2}\tag1
\end{align}$$

Now, let's take a look at $\frac{(2m-1)!!}{(2m)!!}$.  We can write
$$\begin{align}
\frac{(2m-1)!!}{(2m)!!}&=\frac{(2m-1)(2m-3)\cdots (3)(1)}{(2m)(2m-2)\cdots (2)(1)}\\\\
&=\left(\frac{(2m)(2m-2)\cdots (2)(1)}{(2m)(2m-2)\cdots (2)(1)}\right)\left(\frac{(2m-1)(2m-3)\cdots (3)(1)}{(2m)(2m-2)\cdots (2)(1)}\right)\\\\
&=\frac{(2m)!}{(2^m)(m!)(2^m)(m!)}\\\\
&=\frac{(2m)!}{2^{2m}(m!)^2}\\\\
&=\frac{1}{2^{2m}}\binom{2m}{m}\tag2
\end{align}$$

Substituting the left-hand side of $(2)$ into $(1)$ yields
$$\int_0^\pi \cos^{2m}(x)\,dx=\pi \frac{(2m-1)!!}{(2m)!!}$$
as was to be shown!
A: There seems to be a sign error in your expansion of the odd-power integral. It should be
$$
I_{2m-1} = \frac{1}{2^{2m-1}}\sum_{k=0}^{2m-1}{{2m-1}\choose k}\frac{-2}{i(2k-2m+1)}.
$$
Now notice that 
$\binom{2m-1}{2m-1-k} = \binom{2m-1}{k}$
and that
$2(2m-1-k)-2m+1 = -(2k-2m+1),$
and perhaps it will be clearer that the last $m$ terms of the sum exactly cancel the first $m$ terms, leaving a final sum equal to zero.
