# 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 ?

## 1 Answer

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?

• In general, the Principle of Inclusion and Exclusion would apply, but since the fourth powers are a subset of the squares, the problem can be simplified to just the sum of the individual cardinalities minus the overlap. – Acccumulation Nov 13 '17 at 17:51
• How can I prove that numbers which are both perfect squares as well as perfect cubes have to be perfect sixth powers ? – user488460 Nov 13 '17 at 19:12
• @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