TITLE: About $S_n=\{(x,y)\mid \lfloor kx\rfloor=\lfloor ky\rfloor,k=1,2,\cdots n;~x,y\in [0,1]\}$
QUESTION [6 upvotes]: Let $$S_n=\{(x,y)\mid \lfloor kx\rfloor=\lfloor ky\rfloor,k=1,2,\cdots n;~x,y\in [0,1]\}$$
Here are the pictures of $S_1,S_2,\cdots S_{10}$:

We can see that $S_1$ has only one blue region, $S_2$ has $2$ different blue regions. Denote $R_n$ be the number of different blue regions of $S_n,$ then $R_n=1, 2, 4, 6, 10, 12, 18, 22, 28, 32, \cdots$ 
I find that $R_n$ is A002088: $$R_n=\sum_{d=1}^n \phi(d)\tag 1$$
Can you prove $(1)$ ? What's the total area of the blue regions of $S_n$?

REPLY [2 votes]: Proof of (1)
Let $S = \left\{ \dfrac{p}{q} \,|\; 1 \le p \le q \le n \right\}$. Then all the elements of $S$ would lie between $0$ and $1$. Arrange the elements into increasing order and let it be $a_1 < a_2 < \cdots < a_N$ = 1. Also, let $a_0=0$. 
First note that $$N = \sum_{d=1}^{n} \phi(d)$$ since there are exactly $\phi(d)$ number of fraction which the denominator is $d$ in its reduced form. 
If some $a_i = \frac{p}{q}$ lies between $x$ and $y$, then one of $\lfloor qx \rfloor$ and $\lfloor qy \rfloor$ should be smaller than $p$ and one greater or equal to $p$. Thus, for $(x,y)$ to be a element of $S_n$, they must both be in some interval $[a_i, a_{i+1})$. 
On the other hand, if $x, y \in [a_i, a_{i+1})$, there cannot be any $q \le n$ such that there exists a integer $p$ between $qx$ and $qy$. Hence, there are no $q$ which $\lfloor qx \rfloor \neq \lfloor qy \rfloor$ and $(x,y) \in S_n$. 
Now we know that $S_n$ only consists of squares $[a_i,a_{i+1}) \times [a_i,a_{i+1})$ for $i = 0, 1, \cdots, N-1$ and $(1,1)$. Therefore, the number of squares is $R_n = N$.