# Perfect squares, cubes and fifth powers $\leq 10^8$

I've the following question:

Find number of numbers $\leq 10^8$ which are neither perfect squares, nor perfect cubes nor perfect fifth powers.

What I currently have is:

• Number of perfect squares: $n_1 = \sqrt[2]{10^8} = 10^4$.
• Number of perfect cubes: $n_2 = \text{floor}(\sqrt[3]{10^8}) = 464$.
• Number of perfect squares: $n_3 = \text{floor}(\sqrt[5]{10^8}) = 39$.

Where floor(x) is the nearest integer $\leq x$. But, how many numbers are there which are:

• perfect squares and perfect cubes (for eg. $64$)
• perfect squares and perfect fifth powers (for eg. $1024$)
• perfect cubes and perfect fifth powers? (for eg. $32768$)
• If $k$ and $m$ are relatively prime, then a number is a perfect $k$-th power and a perfect $m$-th power if and only if it is a perfect $(km)$-th power. – mjqxxxx Sep 17 '14 at 5:26
• If $n_k(N)$ is the number of perfect $k$-th powers from $1$ to $N$, then you want $N - n_2(N) - n_3(N) - n_5(N) + n_6(N) + n_{10}(N) + n_{15}(N) - n_{30}(N)$, using inclusion-exclusion. – mjqxxxx Sep 17 '14 at 5:28
• @mjqxxxx $n_{30}(N)$ will be floor($\sqrt[30]{10^8}$)? – hjpotter92 Sep 17 '14 at 5:34
• There are about $15\cdot3^{n-2}$ perfect powers below $10^n$. – Lucian Sep 17 '14 at 7:10

A number is a perfect square and a perfect cube if and only if it is a perfect sixth power. The number of positive perfect sixth powers $\le 10^8$ is $\lfloor (10^8)^{1/6}\rfloor$.

Similarly, the numbers that are perfect squares and perfect fifth powers are the perfect tenth powers. The number of these $\le 10^8$ is $(10^8)^{1/10}$.

We can similarly count the numbers that are simultaneously cubes and fifth powers.

To find the number of numbers that are simultaneously squares, cubes, and fifth powers, note that these are the thirtieth powers, and there are $\lfloor(10^8)^{1/30}\rfloor$ of them from $1$ to $10^8$. That is not very interesting in this case, there is only one.

To count the numbers in our interval that are neither squares nor cubes nor fifth powers, we use Inclusion/exclusion.

Call a number bad if it is a perfect square, or perfect cube, or perfect fifth power. We want to count the number $b$ of bad numbers in our interval. Then the answer to our problem is $10^8-b$.

If $A$ is the set of squares, and $B$ the set of cubes, and $C$ the set of fifth powers (all in the interval $1\le x\le 10^8$), then the number of bad numbers can be found by Inclusion/Exclusion. We have $$b=|A\cup B\cup C|=|A|+|B|+|C|-|A\cap B|-|B\cap C|-|C\cap A|+|A\cap B\cap C|.$$ we know how to compute all the numbers on the right.

A positive integer $n$ is a perfect square iff the powers $a_k$ in its prime factorization $$n = p_1^{a_1} \cdots p_m^{a_m}$$ are all multiples of $2$. Likewise, $n$ is a perfect fifth power iff the powers $a_k$ are all multiple of $5$. So it is both iff the $a_k$ are all divisible by both $2$ and $5$, that is if they are all divisible by $10$. In the language of perfect powers, a number $n$ is a perfect square and a perfect fifth power iff it is a perfect $10$th power, and there are $\lfloor \sqrt[10]{10^8} \rfloor = 6$ of these in your interval.

More generally, the same reasoning shows that a positive integer $n$ is a perfect $r$th power and a perfect $s$th power iff it is a perfect $t$th power, where $t := \mathrm{lcm}(r, s)$.