Let $p$ and $q$ are relatively prime integers.
Consider $S = \{\frac{p}{q}\} + \{\frac{2p}{q}\} + \{\frac{(q-1)p}{q}\}$, where $\{x\}$ is the fractional part of the real number $x$.
Prove that $2S$ is divisible by $(q-1)$.
I could not do much with it. May be a very easy problem but I could not do it. $S$ is a fraction, may not a natural number. But $2S$ is an integer and divisible by $(q-1)$, an integer. How ?
Let $S = \sum_{i=1}^{q-1} \{ \frac{ip}{q} \}$. Since $p$ and $q$ are relatively prime, multiplication by $p$ permutes the nonzero residues mod $q$, and so $$ S = \sum_{i=1}^{q-1} \{ \frac{ip}{q} \} = \sum_{i=1}^{q-1} \{ \frac{i}{q} \} = \frac 1q \sum_{i=1}^{q-1} i = \frac 1q \cdot \frac{q(q-1)}{2} = \frac{q-1}{2} . $$