I saw this exercise from the open sourced "Book of Proof", which I'm using in an abstract math class. I could only find out the answer by manually calculating different factorials. But I'm also curious if there is better method for it. Any hint and answers are appreciated!
-
3If you know the number of digits in (for example) $7!$, you can add two digits each for $8\cdot 12$ and $9\cdot 11$ and one for $10$... – abiessu Nov 07 '16 at 04:15
2 Answers
The number of digits of an integer $m$ is $\left\lfloor\log_{10}(m)\right\rfloor+1$. Hence, you're looking for the smallest $n$ for which
$$\left\lfloor\log_{10}(n!)\right\rfloor+1\geq 11$$
or $\left\lfloor\log_{10}(n!)\right\rfloor\geq10$. Now, because $\log(ab)=\log(a)+\log(b)$, we have that this is equivalent to finding the smallest natural $n$ for which
$$\left\lfloor\sum_{k=2}^n\log_{10}(k)\right\rfloor\geq 10$$
and since $\log_{10}(n!)$ will never be an integer (because $n!$ will never be a power of $10$), we might as well rewrite that as
$$\sum_{k=2}^n\log_{10}(k)>10$$
I'm not exactly sure how much better this is, but it's something I guess.
- 23,321
-
I've been thinking about this too, but it seemed to me he is better off calculating the factorials than approximating the logarithms through some series expansion. – Momo Nov 07 '16 at 14:15
-
Yeah, it's a bit hard to use series expansion since the $k$ are moving away from the singularity at the origin. – Fimpellizzeri Nov 07 '16 at 15:37
A way to reduce complexity is by keeping only n (say n=3) significant digits when doing your computations (since you only care about the number of digits). But honestly speaking, what question asks is not that much computationally complex anyway.
If you would have for example $10^{100}$ digits, than it may be useful to use a more or less refined Stirling approximation, depending on your needs.
- 16,300