What's the next base-ten non-pandigital factorial number after 41!?

Solution 1:

According to Stirling’s approximation, $n!$ has

$$ \log_{10}n!\approx\log_{10}\left(\sqrt{2\pi n}\left(\frac n{\mathrm e}\right)^n\right)=\frac12\log_{10}(2\pi n)+n\log_{10}\left(\frac n{\mathrm e}\right) $$

decimal digits. Since $\log_{10}n$ varies slowly, we can approximate it by $\log_{10}42$. Thus,

$$ \log_{10}n!\lesssim1.21+1.19n\;. $$

There is a trailing zero for each factor of $5$, and there are about $n\left(\frac15+\frac1{25}+\cdots\right)=\frac n4$ factors of $5$ in $n!$. The first non-zero digit is known to be even, but that doesn’t change the probability for the number to be pandigital. So we can treat the remaining approximately $1.12+0.94n$ digits as independently uniformly random and find the probability that at least one of the nine non-zero digits is not present. By inclusion–exclusion, this is

$$ \sum_{k=1}^9(-1)^{k+1}\binom9k\left(1-\frac k{10}\right)^{1.12+0.94n}\;. $$

At $n=42$, this is already only about $0.12$. Summing over $n$ yields the expected number of non-pandigital factorials beyond some $n_0$:

$$ \sum_{n=n_0}^\infty\sum_{k=1}^9(-1)^{k+1}\binom9k\left(1-\frac k{10}\right)^{1.12+0.94n}=\sum_{k=1}^9(-1)^{k+1}\binom9k\frac{\left(1-\frac k{10}\right)^{1.12+0.94n_0}}{1-\left(1-\frac k{10}\right)^{0.94}}\;. $$

For $n_0=42$, this is about $1.3$. So we might have expected one more non-pandigital factorial beyond $42!$, but it’s not too much of a coincidence that there turned out to be none. You’ve checked up to $n_0=117583$; the expected number of non-pandigital factorials beyond that is about $3\cdot10^{-5056}$, so you can safely abort your search. (Remember that this is calculated with $\log_{10}n\approx\log_{10}42$, so the value is actually even lower.)