Question 771895
give a procedure for determining the number of zeros at the end of n!.justify your procedure.
<pre>
We will use the "floor" function indicated by  &#8970;x&#8971; to denote the largest
integer that does not exceed x.  Sometimes this is indicated by int(x).

A factorial is a product of integers.  The only thing that will cause a 
zero at the end of a product of integers is a factor of 10, which is a 
pair of factors 2·5.

n! = 1·2·3·4·5·6···n

There are a lot more factors of 2 contained in the members of the sequence 

1,2,3,4,5,6,...,n 

than there are multiples of 5 contained in them.  So there will always be enough 
factors of 2 in n! to pair up with every factor of 5 in n! to cause the pair to
make a factor of 10 causing another zero at the end of 5! 

So we only need to count the total number of 5 factors contained in all the members 
of the sequence

1,2,3,4,5,6,...,n 

Each multiple of 5<sup>1</sup> contributes a 1st 5 factor.

There are n/&#8970;{{{n/(5^1)}}}&#8971; of those. Of those,

each multiple of 5<sup>2</sup> contributes a 2nd 5 factor.  

There are n/ &#8970;{{{n/(5^2)}}}&#8971; of those. Of those,

each multiple of 5<sup>3</sup> contributes a 3rd 5 factor.

There are n/ &#8970;{{{n/(5^3)}}}&#8971; of those. Of those,
...

n/ &#8970;{{{n/(5^k)}}}&#8971; will become 0 when 5<sup>k</sup>
exceeds n.  

So the number of 0's at the end of n! is

&#8970;{{{n/(5^1)}}}&#8971; + &#8970;{{{n/(5^2)}}}&#8971; + &#8970;{{{n/(5^3)}}}&#8971; + ... + &#8970;{{{n/(5^M)}}}&#8971;, 

where M is the largest power of 5 that does not exceed n, or even
larger since values of k > M will all be 0.

We can calculate M, which is the largest value of k such that

5<sup>k</sup> &#8806; n

ln(5<sup>k</sup>) &#8806; n

k·ln(5) &#8806; n

      k &#8806; {{{n/ln(5)}}}

So M = &#8970;{{{n/ln(5)}}}&#8971;

You can write the result as a summation:

Number of 0's at end of n! = {{{sum("",k=1,M)}}}&#8970;{{{n/(5^k)}}}&#8971;, where M = &#8970;{{{n/(ln(5))}}}&#8971; 

Edwin</pre>