TITLE: Compute the integral $\int_{0}^{2\pi}|\cos^n t|\ dt $ for $n \in \mathbb{Z}$
QUESTION [5 upvotes]: I need some help on computing this integral. 
I thought of this when solving another question on S.E. 
Evaluate$$I=\int_{0}^{2\pi} |\cos^n t|\ dt $$ for $n \in \mathbb{Z}$.
Observation: This integral doesn't converge for negative values of $n$, so it would just be sufficient to consider $n \in \mathbb{N}$ where $\mathbb{N}=$ {$0,1,2,...$}
I've tried evaluating this integral for even and odd values of $n$.
Even Values:
For $n=0$, $I=2\pi$
For $n=2$, $I=\pi$
For $n=4$, $I=\frac{3\pi}{4}$
Odd Values:
For $n=1$, $I=4$
For $n=3$, $I=\frac{8}{3}$
For $n=5$, $I=\frac{32}{15}$
The problem is that I am unable to find a pattern in the even and odd "sequences". Any help will be deeply appreciated. I have also searched S.E for this question but nothing came up.

REPLY [5 votes]: For $n$ even, you can drop the absolute value signs, and this becomes a standard beta-type integral, which gives 
$$
\frac{\pi ^2 2^{ n+1}}{\Gamma \left(\frac{1}{2}-\frac{n}{2}\right)^2 n!}$$
For $n$ odd, we make the substitution $u = \sin x,$ whereupon we are integrating
$\int (1-x^2)^{(n-1)/2} d x,$ and we have a sum of such integrals from $0$ to $1.$ Each such integral equals
$$
\frac{\sqrt{\pi } \Gamma (k+1)}{2 \Gamma \left(k+\frac{3}{2}\right)},
$$
where $k=(n-1)/2,$
and there are four of them.