Proving limits involving floor function. 
Let $\theta $ be real, and $0<\theta<1$, define $g_n = 0$ if $\lfloor n\theta\rfloor=\lfloor(n-1)\theta \rfloor$ and $g_n=1$ otherwise. For example, take $\theta = \frac{3}{4}$, then $g_2 =1$, since $\left\lfloor \frac{3}{2}\right\rfloor = 1 \ne 0 =\left\lfloor \frac{3}{4} \right\rfloor$. Prove that $$
\lim_{n \to \infty} \dfrac{g_1+g_2+\cdots + g_n}{n} = \theta$$ Note $\lfloor x \rfloor$ denotes the greatest integer function/ floor function. 

This is what I did: $g_1$ is always $0$, since $\lfloor\theta\rfloor=0$, and $g_2 = 0$ if $\theta \in \left(0,\frac{1}{2}\right)$. Now consier $g_4$, $$
\begin{array}{cccc}
& \left( 0 ,\frac{1}{4}\right) & \left[ \frac{1}{4} , \frac{1}{3} \right) & \left[ \frac{1}{3} , \frac{1}{2} \right) & \left[ \frac{1}{2} , \frac{2}{3} \right) & \left[ \frac{2}{3} , \frac{3}{4} \right) & \left[ \frac{3}{4} , 1 \right) \\ \hline
\lfloor 4\theta \rfloor & 0 & 1 & 1 & 2 & 2 & 3\\ 
\lfloor 3\theta \rfloor & 0 & 0 & 1 & 1 & 2 & 2\\ 
\end{array}$$
Hence $g_4 = 0$ when $\theta \in\left( 0 ,\frac{1}{4}\right) \cup \left[ \frac{1}{3} , \frac{1}{2} \right) \cup \left[ \frac{2}{3} , \frac{3}{4} \right) $ and $g_4 = 1$ otherwise. Similarly, $g_n = 0$ when $\theta \in \left( 0 ,\frac{1}{n}\right) \cup \left[ \frac{1}{n-1} , \frac{2}{n} \right) \cup \left[ \frac{2}{n-1} , \frac{3}{n} \right) \cup \cdots \cup \left[\frac{n-2}{n-1}, \frac{n-1}{n} \right)$ and $g_n=1$ otherwise. Consider the case when $\theta = \frac{p}{q}$ is a rational number with $ p,q>0 \in \mathbb{Z}$ and $p,q$ are copime. Then we see a periodic behaviour, $g_1 = g_{mq+1} = 0$ where $m \in \mathbb{Z_{\ge 0}}$ and $g_i = g_{mq+i}$ for $i \in \{ 1,2,\cdots,q-1\}$. But for irrational $\theta$ I don't even know how to start. Any hints on how to further progess in this problem ? 

Hint: Show that $g_n=\lfloor n\theta \rfloor-\lfloor (n-1)\theta \rfloor$, so that $\sum_{i=1}^n g_n=\lfloor n\theta\rfloor$ by a telescoping sum argument.  So what you need to do is show that 
$$\lim_{n\to\infty}\frac{\lfloor n\theta\rfloor}{n}=\theta$$
which shouldn't be too difficult for you since that is a series of rational approximations that you can show that $|\theta-a_n|<\frac1n$ for all $n$
