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 tryIt 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 ?
$\endgroup$1 Answer
$\begingroup$The number of perfect squares less than $x$ is $\lfloor\sqrt{x}\rfloor$. Similarly for cubes, we use $\lfloor\sqrt[3]{x}\rfloor$. The only ones that have been double-counted are the sixth powers, and there are $\lfloor\sqrt[6]{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[3]{x}\rfloor - \lfloor\sqrt[6]{x}\rfloor$$
Does this work?
$\endgroup$ 3