To simplify $\sum\limits_{k|(2m, 2n), k\nmid m} \varphi(k)$ Consider the Euler phi-function $\varphi(n)$ of $n\in \mathbb N$ as the cardinality of $\{1\leq r\leq n: (r, n)=1\}$. 
I am willing to simplify $$S:=\sum\limits_{k|(2m, 2n), k\nmid m} \varphi(k).$$
I believe the following steps are true:
\begin{align*}
S=&\sum\limits_{k|(2m, 2n), k\nmid m} \varphi(k)\\
 =&\sum\limits_{k|(2m, 2n)} \varphi(k)-\sum\limits_{k| m} \varphi(k)\\
 =&(2m, 2n)-m
\end{align*}
Is this correct ? Please help me.
 A: If $k \mid (2m)$, but $k \nmid m$, then the highest power of $2$ dividing $k$ must be the highest power of $2$ dividing $2m$. If we thus write $m = 2^a\cdot \mu$ with an odd $\mu$, the numbers over which we sum have the form $2^{a+1}\cdot \kappa$ with $\kappa$ odd and $\kappa \mid (m,n)$. If the highest power of $2$ dividing $n$ is smaller than $2^a$, then $2^{a+1} \nmid (2n)$, and our sum is empty. If $2^a \mid n$, then
$$\sum_{\substack{k\mid (2m,2n) \\ k \nmid m}} \varphi(k) = \sum_{\kappa \mid (\mu,n)} \varphi(2^{a+1}\kappa) = \sum_{\kappa \mid (\mu,n)} 2^a\varphi(\kappa) = 2^a \sum_{\kappa \mid (\mu,n)} \varphi(\kappa) = 2^a\cdot (\mu,n) = (m,n).$$
Thus, the sum simplifies to
$$\sum_{\substack{k \mid (2m,2n) \\ k \nmid m}} \varphi(k) = \begin{cases} (m,n) &, v_2(n) \geqslant v_2(m) \\ 0 &, v_2(n) < v_2(m),\end{cases}$$
where $v_p(z)$ is the exponent of the highest power of the prime $p$ dividing $z$.
A: In general, the condition $k|(2m,2n)$ means that either $k=d$, where $d$ is a divisor of $(m,n)$ or $k=2d$ (these conditions may not be exclusive).  
If, say, $m$ is odd then these conditions are exclusive and the additional constraint that $k$ not divide $m$ means that we must have $k=2d$.  In this case, we get:
$$\sum_{d|(m,n)} \varphi(2d)=\sum_{d|(m,n)} \varphi(d)=(m,n)$$
Now suppose that $m=2^aM$, where $M$ is odd.  Similarly, $n=2^bN$. Then $$(2m,2n)=2^{min(a,b)+1}(M,N)$$ 
Thus if $b<a$ there are no $k$ which work. If $b≥a$ then $k$ is anything of the form $2^{a+1}d$ where  and $d|(M,N)$.  Thus your sum is $$\sum_{d|(M,N)}\varphi(2^{a+1}d)=2^a\sum_{d|(M,N)}\varphi(d)=2^a\,(M,N)=(m,n)$$
WARNING:  The above looks error prone and I haven't checked it carefully.  I recommend going over it slowly, and checking several examples.
