0

I'm relatively new to Python and am trying to write a piece of code in which should return the number of trailing zeroes in n!

The following is the code that I've written:

def countzeroes(n):
    count = 0
    i = 5
    while n/i >= 1:
        count += n/i
        i *=5
    return count

print(countzeroes(100))

Now, this code returns a value of 20 to me while it should actually return 24.

I implemented the exact same logic in Java and it returns me a value of 24. Is there a difference in the way the while loop is implemented in Python which is causing my loop to exit after the first iteration.

martineau
  • 119,623
  • 25
  • 170
  • 301

0 Answers0