deffoo(n): s =1for i inrange(1, n +1): s *= i s =str(s) r =0for i inrange(len(s) -1, -1, -1):if s[i]=='0': r +=1else:breakreturn r
Python
classSolution:defthenumberof0(self,n:int) ->int:if n ==0:return0import math c =int(math.log(n, 5)) ret =0for i inrange(1, c +1): ret += n // (5** i)return ret