$\sum_{d|n}(-1)^{\frac nd}\phi(d)={}$? how to find $$\sum_{d|n}(-1)^{\frac nd}\phi(d)=?$$
 A: We consider this sum for parity of $n$ 
If $n$ is odd, then $(-1)^{d}=-1$ for all $d|n$. (Because $d$ is also odd number.) So
$$\sum_{d|n} (-1)^{n/d}\phi(d) = - \sum _{d|n} \phi(d)=-n$$
If $n$ is even, Let take $n=2^r N$, where $N$ is odd number and $r$ is nonnegative integer. Then this sum is represented following form:
$$\begin{align*}
\sum_{d|n} (-1)^{n/d}\phi(d) &= \sum_{i=0}^r \sum _{d|N} (-1)^{n/2^i d} \phi(2^i d) \\
&=\sum_{i=0}^{r-1} \sum_{d|N} (-1)^{n/2^i d} \phi(2^i d) + \sum_{d|N} (-1)^{N/d} \phi(2^r d)\\
&=\sum_{i=0}^{r-1} \sum_{d|N} \phi(2^i)\phi(d) -  \sum_{d|N}\phi(2^r)\phi(d)\\
&=\sum_{i=0}^{r-1} \phi(2^i) \sum_{d|N} \phi(d) -  \sum_{d|N}\phi(2^r)\phi(d)\\
&=2^{r-1}N - 2^{r-1}N=0
\end{align*}
$$
So 
$$\sum_{d|n} (-1)^{n/d}\phi(d) = \begin{cases}
-n & \text{if $n$ is odd} \\
0 & \text{otherwise}
\end{cases}$$
A: If $n$ is odd then $(-1)^{n/d}=-1$ for each $d\mid n$. Otherwise given $n=2^vm$ with $v\ge1$ and $m$ odd,
$$\sum_{d\mid n}(-1)^{n/d}f(d)=\left[\sum_{d\mid 2^{v-1}m}f(d)\right]-\left[\sum_{d\mid m}f(2^vd)\right].$$
Can you take it from here?
A: Hint: For $n \ge 1$, $$\sum_{d|n}\phi(d)=n$$
Let $S=\{1,2,3,\dots n\}$. For every positive divisor $d$ of $n$, let $S_d=\{m \in S  |\gcd(m,n)=d\}$.
Then clearly, these sets $S_d$ are pairwise disjoint and their union is $S$.
Also $\gcd(m,n)=d \iff \gcd\left(\dfrac{m}{d},\dfrac{n}{d}\right)=1$. Hence the number of integers in the set $S_d$ is equal to the number of positive integers $\le\frac{n}{d}$ which are relatively prime to $\frac{n}{d}$ i.e equal to $\phi(\frac{n}{d})$. 
Hence $n= \sum_{d|n} \phi\left(\dfrac{n}{d}\right)$. But as $d$ runs through all positive divisors of $n$, so does $\frac{n}{d}$. Hence
$$\sum_{d|n} \phi\left(\frac{n}{d}\right)=\sum_{d|n} \phi(d)=n.$$
