A sum of fractional parts. I am looking to evaluate the sum $$\sum_{1\leq k\leq mn}\left\{ \frac{k}{m}\right\} \left\{ \frac{k}{n}\right\} .$$
Using matlab, and experimenting around, it seems to be $\frac{(m-1)(n-1)}{4}$ when $m,n$ are relatively prime.  How can we prove this, and what about the case where they are not relatively prime?
Conjecture:  Numerically, it seems that for any $m,n$ we have $$\sum_{1\leq k\leq mn}\left\{ \frac{k}{m}\right\} \left\{ \frac{k}{n}\right\} =\frac{(m-1)(n-1)}{4}+C(\gcd(m,n))$$
where $C(\gcd(m,n))$ is some constant depending only on the $\gcd(m,n)$.
Additionally:  Can we sum this even when it is not a complete interval? Suppose that $0<a<b<mn,$ do we have an exact form for $$\sum_{a\leq k\leq b}\left\{ \frac{k}{m}\right\} \left\{ \frac{k}{n}\right\}.$$ 
Remark: In the one variable case we have $$\sum_{1\leq k\leq n}\left\{ \frac{k}{n}\right\} =\frac{n-1}{2}$$ the sum over an interval $a,b$ has an explicit form.
 A: The fractional parts depend only on the values modulo $n$ and $m$, respectively.
Since you take $m$ and $n$ relatively prime, you can simply let the two instances of $k$ run through all residue classes modulo $m$ and $n$ independently (Chinese remainder theorem). This reduces your question immediately to the product of the one-variable case for $m$ and $n$.
The one-variable case is a direct consequence of the summation formula for the first $n$ integers.
Edited to add:
This means, of course, that an arbitrary interval is not a very good condition on the pair of residues and there is no reason to expect a general closed expression.
A: For the relatively prime case. Split the summation into classes $k \equiv 0 \mod m$, $k \equiv 1 \mod m$, $k \equiv 2 \mod m$ and so on. For $k \equiv r \mod m$, and $1 \leq k \leq mn$ each $k$ leaves a distinct remainder when divided by $n$ since $m$ and $n$ are relatively prime. Hence, the summation is $$\displaystyle \frac{\sum_{r=0}^{n-1} r}{m} \times \frac{\sum_{r=0}^{m-1} r}{n} = \frac{n(n-1)}{2m} \frac{m(m-1)}{2n}$$
EDIT
Consider the class say $k \equiv r \bmod m$. If $(m,n)=1$, then $r,m+r,2m+r,\cdots,(n-1)m+r$ leave different remainders when divided by $n$. If not then $n | (k_1 - k_2)m$ for some $0 \leq k_1,k_2 <n$. Since $(m,n) = 1$, $n|(k_1-k_2)$. Not possible. Hence, summing all the remainders in the class $k \equiv r \bmod m$ gives us $\frac{n(n-1)}{2}$. Hence, the sum of all the fractional parts is $\displaystyle \frac{n(n-1)}{2m}$.
