I am looking for a different way to calculate the following sum where $d,n\in \mathbb N$: $$f(n) = \sum_{d|n; \ \sqrt n\le d \le n}(-1)^d$$ Here are some example results for different values of n (Note that $f(p) = -1$ for all primes p where $p\not=2$):
$f(1)=-1\\f(2)=1\\f(3)=-1\\f(6)=0\\f(10)=0\\f(16)=3\\f(25)=-2\\f(28)=1$