$d(n)$ is odd if and only if $n = k^2$ Can someone help me prove that $d(n)$ is odd if and only if $n = k^2$ for some integer $k$?
For reference:
$d(n)$ gives the number of positive divisors of $n$, including $n$ itself.
 A: Hint: Try to pair every divisor $d$ with $n/d$, which is the only element which would not have a pair?
A: Hint : A number with the prime factorization $p_1^{a_1}\times ...\times p_n^{a_n}$ has
        $(a_1+1)\times ...\times (a_n+1)$ divisors. When is the latter product odd ?
A: Consider $D$, the set of all divisors of $n$. 
Define a map $f: D \rightarrow D$ by $f(d) = \frac{n}{d}$, which is well defined (as $d$ is a divisor of $n$) and self inverse because $f(f(d)) = f(\frac{n}{d}) = \frac{n}{\frac{n}{d}} = d$. 
When $x < \sqrt{n}$ (as reals), then $f(x) > \sqrt{n}$ and vice versa, so $f(x) \neq x$ for all those $x$. So if $\sqrt{n}$ is not an integer, there is no fixed point for $f$ and $D$ is exactly divided in $D_1 = \{d \in D: d < \sqrt{n}\}$ and $D_2 = \{d \in D: d > \sqrt{n}\}$ and these have equal size, as $f$ is a bijection between them. So $|D|$ is even. 
So $n$ no square implies $d(n)$ is even. If $n$ is a square $D = D_1 \cup D_2 \cup \{\sqrt{n}\}$. Again, $f$ shows that $|D_1| = |D_2|$ and $d(n)$ is odd.
