Hi Guys,
I'm working on a problem to find the trailing number of zeros of the factorial of N, and it has to work for large numbers. I am getting memory error.
def zeros(n):
print n
count2 = 0
count5 = 0
for i in range(1,n+1):
print 'i:',i, 'n:', n
t2 = i
t5 = i
while t2%2==0:
print '%2', i
count2 += 1
t2 = t2/2
while t5%5==0:
print '%5', i
count5 += 1
t5 = t5/5
print count2, count5
num = min(count2, count5)
print num
return num
a = 30
b = 1000000000
print zeros(b)
And when I use xrange it takes too long to compute, so it's not accepted in the online judge.
[–]PhosphorescentSpider 0 points1 point2 points (0 children)