Value of $\lim\limits_{n\rightarrow \infty}\frac{1}{n}\int^\pi_0 \lfloor n \sin x \rfloor \, dx$ 
Finding value of $\displaystyle \lim_{n\rightarrow \infty}\frac{1}{n}\int^{\pi}_{0}\lfloor n \sin (x) \rfloor \,dx$

Try: In $0 \leq x<\pi$.  Then $0 \leq\sin (x) \leq 1$. So $0 \leq n\sin (x) \leq n$
So  $$\lim_{n\rightarrow \infty}\frac{1}{n}\bigg(0+1+2+3+\cdots +n-1\bigg)=\lim_{n\rightarrow \infty}\frac{n(n+1)}{2n}$$
What is wrong in my solution?  Help me to solve it.  Thanks.
 A: Your solution is wrong because you are not taking into account the fact that the lengths of the intervals for which $\lfloor n \sin x \rfloor$ take on each nonnegative integer value are not the same.  For example, when $n = 2$, we have $\lfloor 2 \sin x \rfloor = 0$ when $x \in [0, \pi/6)$, but $\lfloor 2 \sin x \rfloor = 1$ when $x \in [\pi/6, \pi/2)$.  As these intervals do not have the same length, the evaluation of the integral is not simply the sum of the values the function takes on; rather, $$\int_{x = 0}^{\pi} \lfloor 2 \sin x \rfloor \, dx = 2 \int_{x=0}^{\pi/2} \lfloor 2 \sin x \rfloor \, dx = 2 \left( 0 \cdot (\pi/6 - 0) + 1 \cdot (\pi/2 - \pi/6)\right).$$
A: HINT:
Note that 
$$\lfloor n\sin(x)\rfloor=n\sin(x)-\{n\sin(x)\}$$
where $\{n\sin(x)\}$ is the fractional part of $n\sin(x)$ and is therefore bounded in absolute value by $1$.
A: Generalizing
Mark Viola's answer,
\begin{align}
I
&=\lim_{n\rightarrow \infty}\frac{1}{n}\int^b_a \lfloor n f (x) \rfloor \,dx\\[8pt]
&=\lim_{n\rightarrow \infty}\frac{1}{n}\int^b_a (nf(x)-\{ n f (x) \}) \,dx\\[8pt]
&=\int^b_a f(x) \, dx-\lim_{n\rightarrow \infty}\frac{1}{n}\int^b_a \{ n f (x) \} \,dx
\end{align}
so
\begin{align}
\left|I-\int^b_a f(x) \, dx\right|
&=\left|-\lim_{n\rightarrow \infty}\frac{1}{n}\int^b_a \{ n f (x) \} \,dx\right| \\[8pt]
&\le\left|\lim_{n\rightarrow \infty}\frac{1}{n}\int^b_a \{ n f (x) \} \,dx\right|\\[8pt]
&\le\left|\lim_{n\rightarrow \infty}\frac{b-a} n \right|\\[8pt]
&\to 0\\
\end{align}
so
$$I=\int^b_a f(x)\,dx.$$
