The sum is this one $$f(n)=\sum_{d^2\mid n}\mu (d)$$ where $\mu (d)$ is the Moebius function and the answer I got to the series that $f(n)=e(\sqrt n)$. I don't know if it is correct. The reasoning that lead me to think that is the answer is the following. Having that $$e(k)=\sum_{d\mid k}\mu (d)$$ Now let the n in $f(n)$ be $m^2$. Therefore, if $d^2\mid m^2$ this means that $d\mid m$ and we substitute this condition on the sum for being equivalent, having $$f(m^2)=\sum_{d\mid m}\mu (d)$$ and thus $$f(m^2)=e(m)$$ and substituting back n we end up with $$f(n)=e(\sqrt n)$$ I am new in this type of problems so it is very possible that I have made an obvious mistake. Please, if that is the case could you explain it to me?
Thank you in advance.
You are on the right track, but there is a small error. As $n$ need not be a perfect square, $\sqrt{n}$ need not be an integer. However, you can uniquely write $n=N^2m$ where $m$ is square-free ($p^2 \nmid m$ for any prime $p$). This is because you can just write the prime factorization of $n$ and divide all the powers by $2$ to get $N$, but if a power is odd, you get a remainder of $1$ and that prime goes to $m$. For example: $$n=2^5 \cdot 3^3 \cdot 5^2 = (2^4 \cdot 3^2 \cdot 5^2) \cdot (2 \cdot 3)=(2^2 \cdot 3 \cdot 5)^2 \cdot(2 \cdot 3) = N^2m$$ Now, if $d^2 \mid n$, it is easy to see that $d^2 \mid N^2$ since $d^2$ contains even powers of primes, and even if $n$ contains odd power of the same prime, you can reduce the power by $1$ since that is all you need. Thus: $$d^2 \mid n \implies d^2 \mid N^2 \implies d \mid N$$ Thus: $$\sum_{d^2 \mid n} \mu(d)=\sum_{d \mid N} \mu(d)=e(N)$$
In the special case that $n$ happens to be a square, we have $n=N^2$ which makes your sum $e(\sqrt{n})$.
Note: We have $e(k)=0$ for all $k \in \mathbb{N}$ where $k>1$. Thus, your answer will be $0$ when $N>1$. If $N=1$, that shows $n=m$ which means that $n$ is square-free. In that case, the answer will be $e(1)=1$.