Relation of log sum and digits of factorial

1.3k Views Asked by At

Today i learned that

floor $(\log 1 + \log 2 + \log 3 + \cdots + \log N ) + 1$

is equivalent to the number of digits of (N!)

I.E. floor ($\log 1 + \log 2 + \log 3 + \log 4 + \log5 ) = 2.$

And $2+1 = 3 =$ digits of $120 (5! = 120).$

Can any one explain how does that work?

2

There are 2 best solutions below

1
On BEST ANSWER

If a number $n$ has $k$ digits, then $10^{k-1}\leq n <10^k.$ Taking (base-10) logs gives $k-1 \leq \log n < k$, so $\mbox{floor}(\log n)+1 = k.$ By rules of logs, we have $\log N! = \log 1+\log 2 + \cdots + \log N.$ Apply these facts to get the number of digits of $N!$ $$ = \mbox{floor}(\log N!)+1 =\mbox{floor}(\log 1+\log 2+ \cdots +\log N) +1.$$

0
On

For a number $\text{x}\in\mathbb{N}^+$, it has a number of digits:

$$\mathcal{N}_\text{x}=\lfloor\log_{10}\left(\text{x}\right)\rfloor+1$$


Now, by definition:

$$\text{n}!:=\text{n}\times\left(\text{n}-1\right)\times\left(\text{n}-2\right)\times\dots\times3\times2\times1$$

For any positive number $\text{a}$ (and $\text{a}\ne1$) we have:

$$\log_\text{a}\left(\text{b}\right)=\frac{\ln\left(\text{b}\right)}{\ln\left(\text{a}\right)}$$

And, when $\text{c}$ and $\text{d}$ are positive numbers:

$$\log_\text{y}\left(\text{c}\cdot\text{d}\right)=\log_\text{y}\left(\text{c}\right)+\log_\text{y}\left(\text{d}\right)$$


So, we get when $\text{x}=\text{n}!$:

$$\log_{10}\left(\text{n}!\right)=\frac{\ln\left(\text{n}\times\left(\text{n}-1\right)\times\left(\text{n}-2\right)\times\dots\times3\times2\times1\right)}{\ln\left(10\right)}=$$ $$\frac{\ln\left(\text{n}\right)+\ln\left(\text{n}-1\right)+\ln\left(\text{n}-2\right)+\dots+\ln\left(3\right)+\ln\left(2\right)+\ln\left(1\right)}{\ln\left(2\cdot5\right)}=$$ $$\frac{\ln\left(\text{n}\right)+\ln\left(\text{n}-1\right)+\ln\left(\text{n}-2\right)+\dots+\ln\left(3\right)+\ln\left(2\right)}{\ln(2)+\ln(5)}$$

So, we get:

$$\mathcal{N}_{\text{n}!}=\lfloor\log_{10}\left(\text{n}!\right)\rfloor+1=\left\lfloor\frac{\ln\left(\text{n}\right)+\ln\left(\text{n}-1\right)+\ln\left(\text{n}-2\right)+\dots+\ln\left(3\right)+\ln\left(2\right)}{\ln(2)+\ln(5)}\right\rfloor+1$$