A number is a perfect square if and only if it has odd number of positive divisors

I believe I have the solution to this problem but post it anyway to get feedback and alternate solutions/angles for it.

For all $n \in \mathrm {Z_+}$ prove $n$ is a perfect square if and only if $n$ has odd # of positive divisors.

$\Rightarrow$: If $n$ is a perfect square it must consist of 1+ prime factors each to an even power. If $n$ consists of 1+ prime factors each to an even power it must have an odd # of positive divisors because each even power contributes itself plus $1$(for the $0$ case) to the number of divisors for product $n$.

$\Leftarrow$: If $n$ has an odd number of positive divisors it must consist of 1+ prime factors each to an even power. If $n$ consists of 1+ prime factors each to an even power it must be a perfect square.

Thanks.


Solution 1:

HINT: Write $n = p_1^{a_1} \dots p_k^{a_k}$, where $p_1, \dots, p_k$ are distinct primes. Then the number of positive divisors of $n$ is given by $(a_1 +1)(a_2 + 1)\dots(a_k+1)$. In order for this number to be odd, each of the terms $a_i + 1$ must also be odd. What does this tell us about each $a_i$?

Solution 2:

If $a$ and $b$ are distinct positive integers such that $ab=n$, call the pair $\{a,b\}$ a couple, or in the business-oriented language of today, partners. Call a positive divisor $a$ of $n$ self-sufficient if $a$ does not have a partner. Note that $a$ is self-sufficient if and only if $\frac{n}{a}=a$, that is, if and only if $n$ is a perfect square and $a$ is its square root.

If $n$ is not a perfect square, the set of positive divisors of $n$ is made up of a number, possibly $0$, of couples, so the number of divisors of $n$ is even.

If $n$ is a perfect square, then the set of of positive divisors of $n$ is made up of a number of couples, together with a self-sufficient number, so the number of positive divisors is odd.