2

Finding total number of digits in $2017!$

Attempt: total number of digits in $n, n \in \mathbb{N}$ is equal to $1+\lfloor \log_{10}(n) \rfloor$

so number of digits in $2017!$ is $\displaystyle 1+\lfloor \log_{10}(2017!)\rfloor$

so $$\log_{10}(2017!) = \log_{10}(1)+\log_{10}(2)+\cdots +\log_{10}(2017)$$

could some help me how to calculate it , thanks

DXT
  • 11,241
  • Which bit of the sum is difficult? – Henry Apr 20 '17 at 17:14
  • Not that hard to do it numerically...I get about $5791.671287$ for the sum. You could use Stirling's approximation but it's less precise. – lulu Apr 20 '17 at 17:14
  • Note: Just ran it with Stirling and got $5791.67127$ for the sum so it is perfectly good enough. But I used a machine for both and the direct computation wasn't any harder. – lulu Apr 20 '17 at 17:18

3 Answers3

4

By Stirling's inequality we have $$ \log(n!) = \left(n+\frac{1}{2}\right)\log n-n+\frac{1}{2}\log(2\pi)+E(n),\qquad 0\leq E(n)\leq \frac{1}{12n}$$ hence the number of digits in $2017!$ is given by $$ 1+\left\lfloor\frac{13335.816}{\log(10)}\right\rfloor = \color{red}{\large 5792}.$$

Jack D'Aurizio
  • 353,855
  • Thanks Jack D'Aurizio , if you have an idea how to solve it without stirling approxamation, then please explain, thanks – DXT Apr 20 '17 at 17:32
  • @DurgeshTiwari: I do not think there is an effective way for avoiding it, without performing a massive amount of computations. – Jack D'Aurizio Apr 20 '17 at 17:33
3

You can approximate the sum of the log's with an integral, so the number of digits should be really close to

$$1+\int_1^{2017} \log_{10} x \; dx = 5791.054122,$$

because the graph of $y= \log_{10} x $ is almost horizontal almost the whole way.

2

Use Stirling's formula $$n!\sim \sqrt{2\pi n}\,e^{-n} n^n.$$ This is very close when $n=2017$. Take the logarithm to base 10 of this estimate; unless it's very close to an integer the number of digits will be $1$ plus the integer part of $\log_{10}\sqrt{2\pi n}\,e^{-n} n^n$ with $n=2017$.

Angina Seng
  • 158,341