The perfect powers are numbers of the form with and . I'm interested in counting the exact number of perfect powers not greater than . I'd like to ask if there's some method much better than enumerating all perfect powers in ?
There's an obvious approach we can do - count the squares, the cubes, the fourth powers, and so on.
But then, we look closer. If we count and , we've just counted twice. All of the fourth powers are already squares; we've already counted them, so we should put zero weight on those fourth powers.
Then, the next place we run into trouble is the sixth powers. We can write ; each sixth power is a square and a cube, already double-counted. We have to subtract the number of sixth powers to balance this.
Is there a pattern to the weights we need here? Why, yes. Let be the Möbius function of number theory. The count we seek is
Now, how many perfect th powers are there in ? There are , which is positive as long as . From that, we get a formula:
Addendum: The original statement with includes as a perfect power. To include that, just add to the count.
Using inclusion-exclusion, the number of perfect powers up to is
Here's a worked example for :
To check your results, you can compare with sequence A089579, which gives the number of perfect powers, excluding , less than . Thus its third entry is , as both and are not counted.