N!의 값을 10으로 나눠주는 과정을 반복하면 간단하게 해결할 수 있을 것이라고 생각했다.
import math N = int(input()) N_factorial = math.factorial(N) cnt = 0 while True: if N_factorial % 10 == 0: N_factorial //= 10 cnt += 1 else: break print(cnt)