Alternating sum of the length of intervals

79 Views Asked by At

Here's the problem

For two odd $m$ and $n$, which are coprime, consider the interval $[0, mn]$ and let $$ A = \{0, m, 2m, \dots , nm\} \quad\text{and}\quad B = \{0, n, 2n, \dots , mn\}. $$ Consider the intervals divided by the elements of $A \cup B$.

Prove that the alternating sum of the lengths of these intervals is equal to $1$.

For example, for $m=3$ and $n=5$ the intervals will be $$ [0,3],\, [3,5],\, [5,6],\, [6,9],\, [9,10],\, [10,12],\, [12,15], $$ and $3-2+1-3+1-2+3 = 1$.

Equivalently, it is enough to prove that $$ \sum_{p=0}^{mn-1} (-1)^{\left\lfloor\frac{p}{n}\right\rfloor + \left\lfloor\frac{p}{m}\right\rfloor} = 1. $$


My Attempt.

For $m \geq 3n$ case, the intervals created by $(m,n)$ can be easily extended from the intervals created by $(m-2n, n)$.

For $m=n+2$ case, it can be proved with direct computation.

So I separated the problem into 2 cases: $n \leq m < 2n$ and $2n \leq m < 3n$.

If $n \leq m < 2n$, let $m=n+r$. Then $r$ is even.

For $n \leq m < 2n$ case, let $a_k = \bigl\lfloor\frac{kn}{r}\bigr\rfloor$. Then by direct calculation, I showed that the result is $$ \sum_{k=1}^{r}{(-1)^{k-1}(a_k -a_{k-1}-1) \bigl( (2k-1)n - (a_k + a_{k-1} +1)r \bigr)} $$ but I couldn't simplify this result...