When I ran the part of the assistant terminal ZeroCount (20), I got 7. When I do 20! with a calculator, it's true that there are 7 zeros, but how do I use this as a string method to get 4?
python
def terminalZerosOfFactorial(n):
fac = 1
for i in range(1, n+1):
fac *= i
s = str(fac)
cnt = 0
while s[-(cnt+1)] != "0":
cnt += 1
return cnt
def terminalZerosOfFactorial(n):
cnt = 0
for i in range(1, n+1):
while i%5 == 0:
cnt += 1
i %= 5
return cnt
© 2025 OneMinuteCode. All rights reserved.