Find the amount of natural numbers that can be written as $x^2$, $x^3$ and $x^5$ that are smaller or equal than $2^{30}$ Since I have not found any formula for this, I've written a quick Python script to calculate the number of numbers that can be expressed as $x^2$ that are $\le2^{30}$, just to see the result.

It took a little while to compute, and it returned $32769$. Wolframalpha says that $32769$ can be represented as $2^{15} + 1$, but I am still not seeing any pattern here.

EDIT: The script started from $0$, which explains the extra $+1$. The actual number of perfect squares that are $\le2^{30}$ is $2^{15} = 32768$.

Also, thanks to Eevee Trainer, I've been able to solve this more efficiently for $x^2$, $x^3$ and $x^5$ using their formula:

$\text{# of positive perfect k-th powers less than or equal to n} = \lfloor \sqrt[k] n \rfloor$

Therefore, these are the number of numbers that are less than or equal to $2^{30}$ for each of the following types:


perfect squares: $\sqrt[2] {2^{30}} = 2^{15}$
cubes: $\sqrt[3] {2^{30}} = 2^{10}$
powers of $5$: $\sqrt[5] {2^{30}} = 2^{6}$
I assume you want positive integers $x$; if it's just any kind of integer (positive or negative or 0), the below can be modified to apply. If it's just any real number, then the number is clearly infinite, but I imagine that's not at all the scope. So going forward, we'll be considering positive perfect squares less than some other number.



First, let's establish the underlying pattern. This will explain why the number of squares is coincidentally equal to $2^{15}+1 = \sqrt{2^{30}} + 1$.

This might be one of those kinds of cases where it's logical to try some small values first.

For example, let's find the number of positive perfect squares $s$ less than or equal to $n$.

Suppose $n=2^2$. Well, we have $s=1,4$. Suppose $n = 3^2$. Then $s=1,4,9$.

Keep trying further numbers, and it becomes clear: if $n$ is a perfect square, then

$$\text{# of positive perfect squares less than or equal to n} = \sqrt n$$

It should be easy to deduce that if $n$ is not a perfect square, it falls between two perfect squares, $\lfloor \sqrt n \rfloor ^2$ and $\lfloor \sqrt{n+1} \rfloor ^2$. But of course, there aren't going to be more perfect squares between the former and $n$, so we can just treat $n$ as the former. Then it can be deduced: for positive integers $n$,

$$\text{# of positive perfect squares less than or equal to n} = \lfloor \sqrt n \rfloor$$

Similar logic follows for the number of perfect cubes or perfect fifth powers or whatever:

$$\text{# of positive perfect k-th powers less than or equal to n} = \lfloor \sqrt[k] n \rfloor$$

(Note: This is by no means a formal argument, nor is meant to be. This is more a heuristic idea to show where the results you need come from.)



Take $n=2^{30} = (2^{15})^2$ to begin to get your solutions. So far, this only gets you $2^{15}$ solutions with respect to the number of squares (i.e. one off). This comes about on the assumption we have positive integer solutions (i.e. $x &gt; 0$) and include the number we're searching at if it's a perfect square (i.e. $"..." \leq 2^{30}$).

The only conclusion I can think of is that $0^2$ is being counted as a further solution. It depends on the exact framing of the question whether that counts - whether you wanted natural number solutions, whether you wanted nonnegative integer solutions, positive integer solutions, etc., and of course to touch on the first whether the problem comes with the implicit assumption that $0$ is a natural number (this a contentious issue in mathematics).

So whether this solution is valid needs to be addressed to whomever gave you the problem.

As for why it might have popped up in your solution and why Wolfram gave the same answer, it depends on the code you used. If you started checking squares at $0$ and not $1$, then  that would explain it, but it depends on your specific implementation. Per a comment from you, it seems that you indeed included $0$ in your search so I figure that's why.
Only the squares up to $x=2^{15}$ satisfy the condition. Obviously there are $2^{15}+1$ of them.