[백준] 1676번 팩토리얼 0의 개수

거북이·2023년 1월 3일
0

백준[실버5]

목록 보기
27/114
post-thumbnail

💡문제접근

N!의 값을 10으로 나눠주는 과정을 반복하면 간단하게 해결할 수 있을 것이라고 생각했다.

💡코드(메모리 : 32540KB, 시간 : 36ms)

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)

💡소요시간 : 1m

0개의 댓글