\[\tau (n)\]
which returns the number of divisors of an integer \[n\]
is odd if and only if \[n\]
is a square number.Suppose
\[n\]
is square number then \[n=p_1^{2k_1}p_2^{2k_2}...p_r^{2k_r}\]
.\[\tau\]
is multiplicative so that if \[r, \; s\]
are relatively prime, then \[\tau (rs)=\tau (r) \tau (s)\]
hence\[\begin{equation} \begin{aligned} \tau (n) &= \tau (p_1^{2k_1}) \tau (p_2^{2k_2})... \tau (p_r^{2k_r}) \\ &= (1+2k_1)(1+2k_2)... (1+2k_r) \end{aligned} \end{equation}\]
The last expression is odd since each factor is odd. If
\[\tau (n)\]
is even then at least one factor \[(1+2k_s)\]
is even bu this is impossible since \[k_s\]
is an integer.