[알고리즘/백준] 6588: 팩토리얼 0의 개수(python)

유현민·2022년 4월 8일
0

알고리즘

목록 보기
113/253

리스트로 변경하여 뒤에서부터 0의 갯수를 체크함


n = int(input())
ans, cnt = 1, 0
while n > 0:
    ans *= n
    n -= 1
for i in list(reversed(str(ans))):
    if i == '0':
        cnt += 1
    elif i != '0':
        break
print(cnt)
profile
smilegate megaport infra

0개의 댓글