1累乘到100的得數有幾個零?
def computeit(limit):
dsts = xrange(1, limit + 1)
b, p = 0, 0
rst = dsts
while rst:
base = 5**p
rst = [x for x in rst if x/base % 5 == 0]
if rst:
b += len(rst)
p += 1
return b
computeit(300)
computeit(500000)
1累乘到100的得數有幾個零?
def computeit(limit):
dsts = xrange(1, limit + 1)
b, p = 0, 0
rst = dsts
while rst:
base = 5**p
rst = [x for x in rst if x/base % 5 == 0]
if rst:
b += len(rst)
p += 1
return b
computeit(300)
computeit(500000)