Given the number of digits for $n!$ where $n \in \mathbb{Z}$ and $n \geq 7$, find the value of $n$.

97 Views Asked by At

I've seen lots of problems about finding the number of digits of $n!$ so I'm just wondering: is there an approach to do the opposite of this process?

An example would be: given the number of digits for $n!$ is $6$, then the value for $n$ would be $9$ since $n! = 362880$, and the number of digits of $n!$ is exactly $6$.

1

There are 1 best solutions below

0
On BEST ANSWER

It is possible to estimate $n$. If you take a number $A$ in base $10$, then $\log_{10}{A}$ is roughly the number of digits $A$ has, i.e. $$A=a_k10^k+a_{k-1}10^{k-1}+...+a_1 10 + a_0, a_i\in \{0,1,...,9\}, a_k\ne0$$ then $$k\leq \log_{10}{A} < k+1 \tag{1}$$ Now, let's consider $$n!=A \Rightarrow k\leq \sum\limits_{i=1}^{n}\log_{10}{i} < k+1 \tag{2}$$ and, since $f(x)=\log_{10}{x}$ is ascending: $$\sum\limits_{i=1}^{n}\log_{10}{i}= \sum\limits_{i=2}^{n}\left[i-(i-1)\right]\log_{10}{i}>\int\limits_{1}^{n}\log_{10}{x}dx =\frac{x(\ln{x}-1)}{\ln{10}}\bigg\rvert_{1}^{n}=\frac{n(\ln{n}-1)+1}{\ln{10}} \tag{3}$$ Combining $(2)$ and $(3)$ $$\frac{n(\ln{n}-1)+1}{\ln{10}} < k+1 \tag{4}$$ In fact, for large enough $k$ we have an asymptotic $$\frac{n(\ln{n}-1)+1}{\ln{10}} \sim k$$ e.g. (applying numerical methods like Newton's for example) $$\frac{n(\ln{n}-1)+1}{\ln{10}}=6 \Rightarrow n \approx 9$$ $$\frac{n(\ln{n}-1)+1}{\ln{10}}=3 \Rightarrow n \approx 6$$