Fog Creek Software
Discussion Board




trailing 0's in factorial hundred

The solution is wrong. The correct answer is 21 becuase the factors of squares of 5 ( 25,50,75) are already covered in the factors of 5.

Chandrashekar Laveti
Friday, May 02, 2003

I guess that 24 is correct .. Because 5 is only taken once when u consider the factors of 5 .... in  25,50 and 75


23 comes because

10 due to 5 in (  5, 15, 25, .... 95)
10 due to 0 in ( 10, 20 , ...... 100)
3 due to additional 5 in ( 25, 50 and 75)
1 due to additional 0 in 100

Rakesh Gupta
Saturday, May 03, 2003

Hi Rakesh,

      Thanks for responding. I just wanted to see how active this discussion board was! :)

Chandu

Chandrashekar Laveti
Sunday, May 04, 2003

Just to add to discussion, there is a mechanical way for calculating trailing zeroes in a n!.There is a explicit formula for that....

If m is the number of trailing zeroes,then
m=sum(i=1 to max) floor(n/5^i)

where max = floor(ln(n) / ln(5))

Arun Iyer
Sunday, June 01, 2003

The correct answer is 23! The reason is that the zeros generated by 50 are alreday accounted for.

one
Monday, June 23, 2003

*  Recent Topics

*  Fog Creek Home