Finding numbers which are squares , cubes or fourth powers in a given range

State the number of positive integers in the range of 1 to 'x' which are perfect squares or cubes or perfect fourth powers of an integer.

My try It would be helpful to find the square root of the nearest perfect square to x and hence know the number of perfect squares . Same could be done with cubes and perfect fourth powers.However , there are some numbers which are both or all three of them and hence would be repeated. E.g. - 1, 64 . Is there another approach to such a problem ?

The number of perfect squares less than $x$ is $\lfloor\sqrt{x}\rfloor$. Similarly for cubes, we use $\lfloor\sqrt{x}\rfloor$. The only ones that have been double-counted are the sixth powers, and there are $\lfloor\sqrt{x}\rfloor$ many of those. There is no need to count perfect fourth powers, because those are all squares, and have thus already been counted. Thus, if you want to count how many perfect powers are less than or equal to $x$ of degree $2,3$ or $4$, your number is: $$\lfloor\sqrt{x}\rfloor + \lfloor\sqrt{x}\rfloor - \lfloor\sqrt{x}\rfloor$$
• @user488460, yes. A perfect $n$th power has the property that all exponents in its prime factorization are multiples of $n$. If a number is a square and a cube, then each exponent is an even multiple of $3$, i.e., a multiple of $6$. – G Tony Jacobs Nov 13 '17 at 19:14