The arithmetic function $\lambda(n)=(-1)^{a_1+\cdots +a_k}$ Define $\lambda(1)=1$, and if $n=p_1^{a_1}\cdots p_k^{a_k}$, define $$\lambda(n)=(-1)^{a_1+\cdots +a_k}$$
How can I see that $$\sum_{d\mid n}\lambda(d)=\begin{cases}
1 \,\,\text{ if $n$ is a square}\\
0 \,\,\text{ otherwise}
\end{cases}
$$?
 A: If you put $f(n)=\sum_{d|n} \lambda(d)$ and 
$$g(n)=\left\{
\begin{array}{c}
 1 & \textrm{if $n$ is square}\\
0 & \textrm{otherwise}
\end{array}
\right.
$$
then you can see easily that if $n,m$ are coprime :
$$
f(nm)=f(n)f(m)\\
g(nm)=g(n)g(m)
$$ 
and 
$$
f(p^k)=g(p^k) \qquad \textrm{for all $p$ prime number}
$$
so $f=g$
A: Define a $b$-tuple on $(a_1,\dots,a_k)$ as $[b_1,\dots,b_k]$ with $0\le b_i\le a_i,\;\forall 1\le i\le k$.
Then if $a_i$ is odd, there are an even number of possibilities for $b_i$, and if $a_i$ is even, there are an odd number of possibilities for $b_i$.
So unless every $a_i$ is even, i.e. $n$ is a square, we have an even number of possible $b$-tuples, with an equal number of odd and even sums.
These represent the divisors of $n$, and so $\sum_\limits{d|n} \lambda(n)=0$ unless $n$ is a square, when there are an excess of even $b$-tuples, and so in this case $\sum_\limits{d|n} \lambda(n)=1$.
A: With the prime factorization of $n$ being
$$n = \prod_p p^v$$
we have
$$\sum_{d|n} \lambda(d)
= \prod_p \left(1 + (-1) + 1 + (-1) + \cdots + (-1)^v\right).$$
Now if $v$ is odd the corresponding factor is zero, so the sum is zero
in this case  as well. Therefore for this to be  non-zero all $v$ must
be even. This yields the value one for the sum terms, producing one as
the end result. But  if all $v$ are even $n$ certainly  is a square as
claimed.
