Oscar Dolloway - 10 months ago 69

Python Question

Trying to calculate the number of trailing zeros in a factorial...

`def count(x):`

zeros = 0

for i in range (2,x+1):

print(i)

if x > 0:

if i % 5 == 0:

print("count")

zeros +=1

else:

("False")

print(zeros)

count(30)

The number of trailing zeros is incorrect I think,

Problem: using

`count(30)`

any ideas ?

Answer Source

```
def count (x):
i = 5
zeros = 0
while x / i >= 1:
zeros += x // i
i *= 5
return zeros
print(count(30))
```