Is there a pandigital perfect power $p^k$ for any prime $p$

decimal-expansionelementary-number-theoryexponentiationprime numbers

A number is pandigital in base 10 if it contains all the digits from $0$ to $9$ in its decimal representation. For example, $541672390489$ is pandigital.

My question is, given a prime $p$, does there exist a positive integer $k$ such that $p^k$ is pandigital? For $p=2$, WolframAlpha tells me that $2^{121}$ is pandigital. In fact, this question allows us to conclude that there are infinitely many $k$ such that $2^k$ is pandigital.

Originally, I was investigating if for a given prime $p$, there was a $k$ such that $p^k$ contained a certain decimal digit. I found How to prove that all primes $p$ will have a power $p^k$ with a $2$ in its decimal representation? , and experimenting with smaller cases led me to believe that this generalised form is true.

I found some questions asking to prove that for any finite sequence of digits there's a power of $2$ that starts with that sequence, though I couldn't find anything similar generalizing to all primes.

Best Answer

For every prime $p$, if there exists one pandigital power of $p$, say $p^k$, then we will have infinitely many pandigital powers as we have infinitely many $n$ such that: $$p^n \equiv p^k \pmod{10^{{\lceil{\log (p^k)}}\rceil}}$$ Thus, for a given prime $p$, it suffices to show that there exists one pandigital power of $p$, to generate infinitely many of them. This can be done in a very nifty maner. Say we have a few of the base-10 representation digits in $p$ (for the sake of example, let us say $p$ has $6$ distinct digits and $17$ digits overall). Now, let $$p^d \equiv 1 \pmod{10^{17}}$$ Now, every $p^{kd+1} \equiv p \pmod{10^{10}}$ will have the $6$ distinct digits in addition to extra digits in the left. However, we know that we can use bounding to control the leading digits of any $a^k$. So, we set $a=p^d$. This gives us control over the first few digits of $p^{kd}$. Say we require a $2$ in the decimal representation. We can find some value $s$ such tha: $$10^ls<p^{kd}<10^l(s+1)$$ where $s$ is going to be the starting of the decimal expansion of $p^{kd}$. Then, we have: $$10^lsp<p^{kd+1}<10^l(s+1)p$$ So, all we need to do is find $s$ such that $2 \cdot 10^m<sp<(s+1)p<3 \cdot 10^m$ which is trivial. We can now continue this process for the other $2$ distinct digits if not obtained already.

Example, let $p=7$. First, we need a $1$. We have $7$ already and $7^4 \equiv 1 \pmod{10^1}$. So, we are looking for some $7^{4k+1}$ starting with $1$. As we need $10^m < 7s < 8s < 2 \cdot 10^m$, we can use $s=2$. Now, we can set $s=2$ as the starting of $7^{4k}=2401^k$, which happens for $k=1$. Thus, we have: $$7^{4k+1}=7^5=16807$$ which preserves the $7$ at the end as well as acquires a few new digits. We can repeat this process till we acquire a pandigital power of $7$.

Related Question