k2c901_1 wrote:
Let $p,q$ be two distinct odd primes. Calculate
$\displaystyle \sum_{j=1}^{\frac{p-1}{2}}\left \lfloor \frac{qj}{p}\right \rfloor +\sum_{j=1}^{\frac{q-1}{2}}\left \lfloor \frac{pj}{q}\right\rfloor$.
You will see the answer if you consider this picture: all the lattice points inside the rectangle $0<x<\frac{p-1}{2}$ and $0<y<\frac{q-1}{2}$,
and the line $y/x = q/p$, which partitions the lattice points into two sets.
The problem does not change if we allow $p$ and $q$ to be any odd relatively prime natural numbers.
This expression arises in a widely published proof (adapted from Eisenstein) of the quadratic reciprocity theorem.
A slightly related result is Beatty's theorem:
http://en.wikipedia.org/wiki/Beatty's_theorem
http://www3.telus.net/ldh/math/beatty.htm