Factorial Rocks!

What is the trailing number of zeros that 500 ! 500! have?

124 None 421 241

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Sravanth C.
Jan 26, 2016

The number of trailing zero's of 500 ! 500! will be k = 1 3 500 5 k = 500 5 + 500 5 2 + 500 5 3 = 100 + 20 + 4 = 124 \displaystyle \sum_{k=1}^3 \left\lfloor{\frac{500}{5^k}}\right\rfloor= \left\lfloor{\frac{500}{5}}\right\rfloor+ \left\lfloor{\frac{500}{5^2}}\right\rfloor+ \left\lfloor{\frac{500}{5^3}}\right\rfloor\\=100+20+4=\boxed{124}

This one is so common that I've written a code to compute this :p

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
n = int(raw_input())
c = 5

r = n // c

count = 0

while r > 0:
    count += r
    c *= 5
    r = n // c

print count

Arulx Z - 5 years, 4 months ago

Log in to reply

Cool! Why not post it as a solution?

Sravanth C. - 5 years, 4 months ago

Log in to reply

Sure! Done.

Arulx Z - 5 years, 4 months ago

Log in to reply

@Arulx Z Great! +1!

Sravanth C. - 5 years, 4 months ago

Log in to reply

@Sravanth C. Thanks a lot :)

Arulx Z - 5 years, 4 months ago
Arulx Z
Jan 26, 2016

As Sravanth pointed out, we just need to count the power of 5's.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
n = int(raw_input())
c = 5

r = n // c

count = 0

while r > 0:
    count += r
    c *= 5
    r = n // c

print count

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...