I am writing a program to generate a sequence of numbers such that they are not of the form $p^{2^n}$, where $n$ can be a whole number ( i.e $ n \in \{ 0, 1, 2, 3, \ldots \} $ ).
I could use the following approach (solve for n):
$$ p^{2^n} = N \\ 2^n log(p) = log(N) \\ n log(2) = log(\frac{log(N)}{log(p)})\\ n = \frac{1}{log(2)} . log(\frac{log(N)}{log(p)}) $$
I can increment $p$ and test if $n$ is a whole number. But for numbers which are not of the said form, I don't know when to stop the program and decide that this is not a number of the said form.