[Tutor] puzzled again by decimal module

Tim Peters tim.peters at gmail.com
Sat Aug 19 03:07:11 CEST 2006


[Dick Moores, computes 100 factorial as
 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000

 but worries about all the trailing zeros]

> <BLUSH> Yes, I'm sure you are. I'd forgotten about all those factors
> of 100! that end in zero (10, 20, 30, ..., 100).

And others, like 2 and 5 whose product is 10, or 4 and 25 whose product is 100.

For a fun :-) exercise, prove that the number of trailing zeroes in n!
is the sum, from i = 1 to infinity, of n // 5**i (of course as soon as
you reach a value of i such that n < 5**i, the quotient is 0 at that i
and forever after).

In this case,

100 // 5 + 100 // 25 + 100 // 125 + ... =

20 + 4 + 0 + ... =

24


More information about the Tutor mailing list