<s>[INST] Proof of $\sum_{j=1}^{p-1} \lfloor jq/p \rfloor = \frac{1}{2}(q-1)(p-1)$ Involving Pairing of Summands I've seen the proof of the identity
$$\sum_{j=1}^{p-1} \lfloor jq/p \rfloor = \frac{1}{2}(q-1)(p-1)$$ 
where $p$ and $q$ are coprime positive integers. This involves counting the remainders $r_{j}/p$ of the summands $\lfloor jq/p \rfloor = jq/p - r_{j}/p$. But when I attempted at showing the identity, I used the fact that if $kq/p = n + \alpha$ for some $\alpha < 1$ (which is nonzero since $p$ and $q$ are coprime) and some integer $n$, then we can pair up the summands
$$\big\lfloor kq/p \big\rfloor + \big\lfloor \dfrac{(p-k)q}{p} \big\rfloor = n + q - (n + 1) = q-1.$$
There are $(p-1)/2$ such pairs in the sum if $p$ is odd, and thus we get $(p-1)(q-1)/2$. If $p$ is even, then $q$ is odd and there are $(p-2)/2$ such pairs, with an extra term $\lfloor (p/2)(q/p)\rfloor = (q-1)/2$. Thus we have 
$$\dfrac{(q-1)(p-2)}{2} + \dfrac{q-1}{2} = \dfrac{(p-1)(q-1)}{2}$$
as desired. 
My question is: Is there something I might be missing in this argument? I can't find a similar one anywhere else, which makes me think that there is a hole somewhere. But I cannot find anything in my view, so maybe others' views will help. 
 [/INST] Your procedure is correct, in fact your steps can be reformulated as follows:
$$
\eqalign{
  & \sum\limits_{j = 1}^{p - 1} {\left\lfloor {j\,q/p} \right\rfloor }  = {1 \over 2}\left( {\sum\limits_{j = 1}^{p - 1} {\left\lfloor {j\,q/p} \right\rfloor  + \sum\limits_{j = 1}^{p - 1} {\left\lfloor {\left( {p - j} \right)\,q/p} \right\rfloor } } } \right) =   \cr 
  &  = {1 \over 2}\sum\limits_{j = 1}^{p - 1} {\left( {\left\lfloor {j\,\left\lfloor {q/p} \right\rfloor  + j\left\{ {q/p} \right\}} \right\rfloor  + \left\lfloor {\left( {p - j} \right)\,\left\lfloor {q/p} \right\rfloor  + \left( {p - j} \right)\left\{ {q/p} \right\}} \right\rfloor } \right)}  =   \cr 
  &  = {1 \over 2}\sum\limits_{j = 1}^{p - 1} {\left( {p\,\left\lfloor {q/p} \right\rfloor  + \left\lfloor {j\left\{ {q/p} \right\}} \right\rfloor  + \left\lfloor {\left( {p - j} \right)\left\{ {q/p} \right\}} \right\rfloor } \right)}  =   \cr 
  &  = {1 \over 2}\sum\limits_{j = 1}^{p - 1} {\left( {p\,\left\lfloor {q/p} \right\rfloor  + p\left\{ {q/p} \right\} + \left\lfloor {j\left\{ {q/p} \right\}} \right\rfloor  + \left\lfloor { - j\left\{ {q/p} \right\}} \right\rfloor } \right)}  \cr} 
$$
and since:$$
\left\lfloor x \right\rfloor  + \left\lfloor { - x} \right\rfloor  = \left\lfloor x \right\rfloor  - \left\lceil x \right\rceil  =  - \left[ {0 < \left\{ x \right\}} \right]
$$
where the square brackets are the Iverson bracket, and because:$$
\gcd (q,p) = 1\quad  \Rightarrow \quad \gcd \left( {q\bmod p,p} \right) = 1\quad  \Rightarrow \quad 0 < \left\{ {j\left\{ {q/p} \right\}} \right\}\,\;\left| {\,1 \le j \le p - 1} \right.
$$
then the above converts to:$$
 = {1 \over 2}\sum\limits_{j = 1}^{p - 1} {\left( {q - 1} \right)}  = {{\left( {p - 1} \right)\left( {q - 1} \right)} \over 2}
$$
---- addendum (in reply to om joglekar) ---
We can write the duplicated summand as
$$
\begin{array}{l}
 \left\lfloor {\frac{{jq}}{p}} \right\rfloor  + \left\lfloor {\frac{{\left( {p - j} \right)q}}{p}} \right\rfloor  =
 \left\lfloor {\frac{{jq}}{p}} \right\rfloor  + \left\lfloor {q - \frac{{jq}}{p}} \right\rfloor  =  \\ 
  = q + \left\lfloor {\frac{{jq}}{p}} \right\rfloor  + \left\lfloor { - \frac{{jq}}{p}} \right\rfloor  =
 q + \left\lfloor {\frac{{jq}}{p}} \right\rfloor  + \left\lfloor { - \left( {\left\lfloor {\frac{{jq}}{p}} \right\rfloor
  + \left\{ {\frac{{jq}}{p}} \right\}} \right)} \right\rfloor  =  \\ 
  = q + \left\lfloor {\frac{{jq}}{p}} \right\rfloor  - \left\lfloor {\frac{{jq}}{p}} \right\rfloor
  + \left\lfloor { - \left\{ {\frac{{jq}}{p}} \right\}} \right\rfloor  =
 q + \left\lfloor { - \left\{ {\frac{{jq}}{p}} \right\}} \right\rfloor  \\ 
 \end{array}
$$
Now the fractional part is limited to be
$$
0 \le \left\{ x \right\} < 1
$$
Since $\gcd(q,p)=1$ and $1 \le j \le p-1$ the fraction $j q / p$ cannot be an integer, hence its fractional part will never be zero.
Therefore
$$
0 < \left\{ {\frac{{jq}}{p}} \right\} < 1\quad  \Leftrightarrow \quad  - 1 <  - \left\{ {\frac{{jq}}{p}} \right\} < 0
$$
and the floor of that will be constant at $-1$.
</s>