# What is the total number of zeroes in n!?

What is the total number of zeroes in $n!$?

I do not want to know the number of trailing zeroes in $n!$.

Let us take an example to understand what I want to know.

$7! = 5040$. The number of trailing zero in $7!$ is $1$. But the total number of zeroes in $7!$ is $2$.

I would like to know if there is any formula that gives me directly the total number of zeros in $n!$.

Can you help me derive one?

-
To the best of my knowledge, there is no known method (apart from calculating the base 10 representation and counting the zeros) of calculating the number of non-trailing zeros. This might be useful. – Old John Dec 29 '12 at 11:41
– mt_ Dec 29 '12 at 13:37
@Sultan In the english language, by convention, there is no space between a sentence and its ending punctuation, whether that's a period, a question mark, or an exclamation mark. There should also be no space before a colon, semicolon, or comma. The only punctuation mark that sometimes needs to be preceded by a space is a dash. I have edited the post making these changes. – user17762 Dec 29 '12 at 19:22

## 2 Answers

Look at the answers and comments related to a similar question in this Mathoverflow link: http://mathoverflow.net/questions/102092/number-of-zeroes-in-100-factorial

-

You can use the Digit Count Algorithm.

Lets do a few examples using WolframAlpha.

Example 1: DigitCount[7!, 10, 0] results in 2.

Example 2: DigitCount[1000!, 10, 0] results in 472.

Example 3: DigitCount[123456!, 10, 0] results in 85245

Alternates for you to explore:

$(1)$ Do you see a way of constructing an algorithm that divides by the two prime numbers $2 ~~ and ~~ 5$ to count the number of zeros?

$(2)$ There are programs that convert an integer to a string and count the number of zeros, but you can look those up.

Regards

-
Answer of your query : 1. Yes I know formula to count the number of trailing zeroes in factorial of n . 2. I do not want to count no of zeroes in n! by program . I know by programming , that is an extremely easy task . But I want to count by myself . N.B. I do not find formula for DigitCount[n!, 10, 0] in your link . Can you help me in this regard ? – Way to infinity Jan 1 '13 at 3:56
I think you are missing the point of Alternate number 1, you can use that to count ALL of the zeros, take your 7! example and work through it and see if you can figure it out. I just checked the link and it is the DigitCount above, but here it is again mathworld.wolfram.com/DigitCount.html (the formula is on this web page). I am not sure you will be able to count the number of zeros manually or in your head as n! grows very quickly. Regards – Amzoti Jan 1 '13 at 4:00
No zero votes allowed for my friend! +1 – amWhy May 10 '13 at 1:17