If $S(a,b)= \{ k \in \mathbb{Z} \mid a ~ (\mathrm{mod} ~ k) + b ~ (\mathrm{mod} ~ k) \ge k \}$, calculate the following sum
$$\sum_{k\in S(m,n)}\varphi(k)$$ where $\varphi$ is Euler's totient function.
I have noticed that all $k$'s such that $$\max(a,b) < k \le a + b$$ are in $S(a,b)$.
(One more not important note) it seems that $$k \in S(n,n) \iff n ~ (\mathrm{mod} ~ k) \ge \left\lfloor \frac{n}{2} \right\rfloor$$
However, I still haven't discovered any way to actually solve the problem. Your help is appreciated.
Now that's a nice little problem. We don't need much to solve it, just the known fact that $\sum\limits_{k|n}\varphi(k)=n$, and a little insight.
Apparently, $S(a,b)$ is complicated and won't be described easily. But we don't really need that. Let's see how is $S(a,b)$ different from $S(a,b-1)$.
What happens when we add $1$ to the (second) argument? Well, $b\pmod k$ either increases by $1$ or drops to $0$, depending on $k$. Consequently, some numbers vanish from the set, and some other numbers join it, and the rest stay where they were.
† Technically, those $k$ which are also divisors of $a$ (if any) must be excluded from both sets, but that's not important. We may just as well consider them included, for they will cancel out in the end.
Let's call the sum in question $Sum(a,b)$. Together with the fact mentioned earlier, we have $Sum(a,b)-Sum(a,b-1) = \sum\limits_{k|a+b}\varphi(k) - \sum\limits_{k|b}\varphi(k) = a+b-b = a$. Together with the obvious $S(a,0)=\emptyset\iff Sum(a,0)=0$ we have the final result: $$Sum(a,b) = a\cdot b$$
So it goes.