How do I find the sum using non-brute force method? How many number $X$ less than $350$ exist such that the sum of the number 
of divisors of X and the number of divisors of the square of $X$ is $60$
I know how to find the number of divisors without listing them all out.
Example :
  $150 = 2\cdot 3\cdot 5\cdot 5 = 2^1\cdot 3^1\cdot 5^2$
Checking each and every number till $344$ excluding prime numbers is really time consuming.
We can exclude prime numbers as any prime number has only two divisors and its square has $3$.
Can we solve this problem differently ?
Please help.
 A: Now that's a nice little problem! For starters, the number of divisors depends only on the prime signature of a number, hence we just need to find the right signatures, which should be not that hard...
There comes the big revelation: a number is a square iff it has an odd number of divisors. So the number of divisors of $X^2$ is odd. For the sum to be 60 (which is even), the other number must have an odd number of divisors too - that is, $X$ itself has to be a square.
So instead of 350 numbers we just have to check the 18 squares that are among them. Quite a significant improvement, as to me. Shall we look further, or just bruteforce our way through?
OK, one more thing to consider: if $X$ is a prime power, that is, $X=p^{2k}$, then it has $2k+1$ divisors, and its square has $4k+1$, which sums up to $6k+2$, which would never be 60. That excludes the squares of 2, 3, 4, 5, 7, 8, 9, 11, 13, 16, and 17, and leaves us with just seven numbers. Seriously, it would be quicker to check them all than to elaborate further.
But well, let's be generous and assume it was $350\,000$ instead of $350$. Let's finish that business with signatures. Let $X=n^2$.
$$\begin{array}{l|c|c|l}
\text{Signature of n}& \tau(X)& \tau(X^2)& \text{verdict} \\ \hline
\{k\}& 2k+1 & 4k+1 & \text{no good, see above} \\
\{1,1\}& 9 & 25 & \text{too few} \\
\{1,2\}& 15 & 45 & \text{that's it!} \\
\{1,3\}& 21 & 65 & \text{too many} \\
\{2,2\}& 25 & 81 & \text{too many} \\
\{1,1,1\}& 27& 125& \text{too many} \\
\end{array}$$
So it turns out that the only good signature is $\{1,2\}$, therefore all numbers we need are of the form $p^2q^4$ with different primes $p,\;q$.
Well, it is not going to be any faster than that.
