Let $n \in \mathbb{Z}$ with $n > 0$. Let $F(n) = \sum_{d \mid n} \lambda(d)$. Prove that $$F(n) = \begin{cases}1, \quad \text{if }n \text{ is a perfect square}\\ 0, \quad \text{otherwise} \end{cases} $$
By the Fundamental Theorem of Arithmetic, all $d$'s admit a prime factorization $d=p_1^{a_1}p_2^{a_2}\cdots p_k^{a_k}$ for primes $p_i$ and nonnegative integers $a_i$. So $\lambda(d)=\lambda(p_1^{a_1}p_2^{a_2}\cdots p_k^{a_k})$. Now the idea is that all the divisors will cancel in pairs of $1$ and $-1$ when $n$ is a perfect square, except the divisor $1$, and so the sum will total $1$. How do I prove this rigorously? If I just choose a generic divisor and write it's prime factorization I don't find anything I can generalize. Can you help?