Trailing zeros of 100!

Robin Koch robin.koch at t-online.de
Sat Jan 2 10:54:23 EST 2016


Am 02.01.2016 um 12:49 schrieb katye2007 at gmail.com:

> I'm trying to write a python program to find how many trailing zeros
> are in 100! (factorial of 100). I used factorial from the math
> module, but my efforts to continue failed. Please help.

Using not Python, but math:

Every "0" at the end of 100! represents a multiplication by the factor 
10 or the factors 2 and 5.

There are 20 numbers with at least one factor 5.
There are  4 numbers with at least two factors 5 (=25).
There are no numbers with three factors 5 (=125).

There are 50 numbers with at least one factor 2.

So 100! contains 24 factors 5 and even more factors 2.
So 100! contains 24 facotrs 10 and therefore has 24 trailing zeros.

-- 
Robin Koch



More information about the Python-list mailing list