45

One common math puzzle I've seen around asks for how many zeros are in the product of "100!"

Usually, the solution everyone gives goes something like try to match pairs of 5s and 2s that factor out of the numbers, which ends up being 24 zeroes (you can factor a 5 out of 20 of the numbers, and factor 2 5s out of 4 of the numbers; you can factor more than 24 2s out).

This however as far as I know gives the number of trailing zeroes at the end of the number, but does not account for the zeroes that are within the number. My question is, is this answer correct anyways? Can there be zeroes that aren't trailing that are inside? Why or why not and if there can be can we somehow figure out how many are within the product?

Thanks

Matt
  • 2,979
  • http://www.wolframalpha.com/input/?i=100+factorial There are zeros other than the trailing zeroes at the end of the number. – Samuel May 07 '12 at 07:39
  • I think it's a much much harder problem. – Long May 07 '12 at 07:39
  • 19
    I am not aware of any way to predict the number of non-trailing zeros in $n!$, other than by calculating n! and counting them. – Robert Israel May 07 '12 at 07:41
  • 1
    See also https://oeis.org/A137581 – Robert Israel May 07 '12 at 07:47
  • 1
    According to WolframAlpha it would be $29$ zeros in $100!$ (trailing $24$ and $5$ zeroes inside), but if you are looking for a method, as Robert Israel said, there is no known method. – Kirthi Raman May 07 '12 at 11:22
  • 4
    I would expect that for large $n$ about one-tenth of the digits should be zero, simply because there's no good reason to expect otherwise. The number of digits of $n!$ can be estimated very well by Stirling's formula. – Gerry Myerson Jul 07 '12 at 05:26
  • The answer is given by this sequence: https://oeis.org/A027869 (contains no elementary formula) – Listing Jul 07 '12 at 11:01
  • @GerryMyerson: There are $158$ digits in $100!$, and accounting for the lead digit, the $24$ trailing zeroes, and the digit prior to the trailing zeros, there are $132$ digits that could be zero. As you say, one would expect about $13$ or so zeros, but in actuality, there are only $6$. – robjohn Jul 07 '12 at 11:27
  • 1
    @robjohn, 100 is not large. – Gerry Myerson Jul 07 '12 at 11:42
  • @GerryMyerson: True. However, the expected mean is $\mu=13.2$ with a variance of $\sigma^2=11.88$. $6$ is a bit over $2\sigma$ below mean, with a probability of less that $2$%. It seemed a bit significant to me; perhaps I am just easily impressed :-) – robjohn Jul 07 '12 at 13:56
  • 1
    @robjohn,if it has a probability of less than 2 percent, that means you'd expect to see it happen if you looked at, say, all the $n!$ with $50\le n\le150$. I refuse to be impressed by a single data point. Show me a trend. – Gerry Myerson Jul 08 '12 at 03:37
  • 1
  • Related: https://math.stackexchange.com/questions/141196 – Watson Nov 29 '18 at 09:12

2 Answers2

13

For a prime $p$, let $\sigma_p(n)$ be the sum of the digits of $n$ when written in base-$p$ form. Then the number of factors of $p$ that divide $n!$ is $$ \frac{n-\sigma_p(n)}{p-1} $$

There are $24$ trailing zeroes in $100!$. Since $100_{\text{ten}}=400_{\text{five}}$, there are $\frac{100-4}{5-1}=24$ factors of $5$ in $100!$.

However, there are $6$ other zeros that occur earlier, making the total $30$:

$933262154439441526816992388562667\color{#C00000}{00}49\color{#C00000}{0}71596826438162146859296389$ $52175999932299156\color{#C00000}{0}894146397615651828625369792\color{#C00000}{0}82722375825118521\color{#C00000}{0}$ $916864\color{#C00000}{000000000000000000000000}$

Matt
  • 133
robjohn
  • 345,667
  • 13
    Counting the amount of zeroes from the explicit form kind of kills the point of doing your first observation. – Listing Jul 07 '12 at 11:50
  • @Listing: It does, but I had written the first part before I pulled out Mathematica to compute $100!$. I left it in because I like the formula, and because I used it in a comment to lab bhattacharjee's answer. – robjohn Jul 07 '12 at 14:01
  • 1
    would the downvoter care to comment? – robjohn Jul 25 '14 at 10:51
  • It is funny that zeroes are relatively rare before the final zero part. – VividD Apr 19 '15 at 09:21
  • +1 from me. You are 185k rep, you know by now, the haters hate. And rarely explain their DV. This was a brilliant answer. If I run into this problem in the future, it will be a pleasure to present this solution. – JTP - Apologise to Monica Feb 22 '16 at 14:12
  • How did you calculate 100! ? A normal calculator goes upto 69! – N.S.JOHN Jul 30 '16 at 04:26
  • @N.S.JOHN: Any computer algebra system, such as Mathematica, Matlab, Macsyma etc, should handle arbitrarily large numbers. I used Mathematica. – robjohn Jul 30 '16 at 05:30
1

If you want to learn how many trailing zeroes are there in a factorial, it is

$\frac{N}{5} + \frac{N}{5}^2 + \frac{N}{5}^3 ..... \frac{N}{5}^{(m-1)} WHERE (\frac{N}{5}^m)<1$

You can learn here how this formula comes at

https://www.youtube.com/watch?v=wdz_KouqHx4

Sagar Chand
  • 1,682