Evaluate the following limit of finite sum Evaluate the limit $$\lim_{n\to \infty}\frac{1}{n}\sum_{k=0}^{[n/2]}\cos \left(\frac{k\pi}{n}\right)$$
I tried through considering two cases : (i) When $n$ is even (ii) when $n$ is odd.
When $n$ is even then the limiting value is $\frac{1}{\pi}$. But when $n$ is odd then ??
Case 1 : $n$ is even..
Then , take $n=2p$ where $p$ is positive integer. Then $$\lim_{n\to \infty}\frac{1}{n}\sum_{k=0}^{[n/2]}\cos \left(\frac{k\pi}{n}\right)$$
$$=\lim_{p\to \infty}\frac{1}{2p}\sum_{k=0}^{p}\cos\left(\frac{k\pi}{2p}\right)$$
$$=\frac{1}{2}\int_0^1\cos(\pi x/2)\,dx$$
$$=\frac{1}{\pi}.$$
Case 2 : When $n$ is odd.
Take, $n=2p+1$ , where $p$ is a positive integer. Then , 
$$\lim_{n\to \infty}\frac{1}{n}\sum_{k=0}^{[n/2]}\cos \left(\frac{k\pi}{n}\right)$$
$$=\lim_{p\to \infty}\frac{1}{2p+1}\sum_{k=0}^p\cos\left(\frac{k\pi}{2p+1}\right)$$
From here how I proceed ?
 A: When $n$ is even, the last term in the sum is zero, since $\cos (\pi/2)=0$.  Therefore, the last term can be discarded, making the sum $1/\pi$ times the Riemann sum for the integral
$$
{\cal I}:=\int_0^{\pi/2} \cos x \, dx
$$
with intervals
$$
[0,\frac{\pi}{n}], [\frac{\pi}{n}, \frac{2\pi}{n}], \dots, [\frac{((n/2)-1)\pi}{n}, \frac{\pi}{2}]
$$
and where $\cos x$ is evaluated at the smallest point in each interval.
When $n$ is odd, the sum is $(n+1)/(n\pi)$ times the Riemann sum for $\cal I$ with intervals
$$
[0, \frac{\pi}{n+1}], [\frac{\pi}{n+1}, \frac{2\pi}{n+1}], \dots, [\frac{((n-1)/2)\pi}{n+1}, \frac{\pi}{2}]
$$
and where, in the interval $[k\pi/(n+1), (k+1)\pi/(n+1)]$, $\cos x$ is evaluated at the point $x=k\pi/n$.
Alternately, for $n$ odd, you could replace the last term ($k=(n-1)/2$) in the sum by
$$\frac{1}{2} \cos \frac{((n-1)/2)\pi}{n}$$
since this changes the sum by at most a constant, which vanishes in the limit when divided by $n$.  After doing this, the sum is $1/\pi$ times the Riemann sum for $\cal I$ with intervals
$$
[0, \frac{\pi}{n}], [\frac{\pi}{n}, \frac{2\pi}{n}], \dots,  [\frac{((n-3)/2)\pi}{n}, \frac{((n-1)/2)\pi}{n}], [\frac{((n-1)/2)\pi}{n}, \frac{\pi}{2}]
$$
and where $\cos x$ is evaluated at the smallest point in each interval.
Whichever method you use for $n$ odd, since ${\cal I}=1$ and $\lim_{n\to\infty} (n+1)/(n\pi)=1/\pi$,
the value of the limit is $1/\pi$.
A: $\color{purple}{\text{Alternatively}}$, one may apply the classic identity (proved here):
$$
\sum_{k=1}^{n} \cos (k\theta)=\frac{\sin(n\theta/2)}{\sin(\theta/2)}\cos ((n+1)\theta/2),
$$ by putting $n \to [n/2]$, $\theta=\dfrac \pi n$, to get the closed form
$$
\color{purple}{\frac{1}{n}\sum_{k=0}^{[n/2]}\cos \left(\frac{k\pi}{n}\right)}=\frac{1}{n}+\frac{1}{n}\frac{\sin([n/2]\pi/(2n))}{\sin(\pi/(2n))}\cos (([n/2]+1)\pi/(2n))
$$ Then observing that, as $n \to \infty$,
$$
\frac{[n/2]}{2n} \to \frac14, \quad \frac{1}{n}\frac{1}{\sin(\pi/(2n))} =\frac 2 \pi\frac{\pi/(2n)}{\sin(\pi/(2n))}\to \frac 2 \pi, 
$$ we readily obtain
$$
\color{purple}{\frac{1}{n}\sum_{k=0}^{[n/2]}\cos \left(\frac{k\pi}{n}\right)} \longrightarrow 
\frac 2 \pi \sin (\pi/4)\cos (\pi/4)=\color{purple}{\frac 1 \pi}.
$$
