티스토리

프로그래밍 블로그
검색하기내 프로필
Python/BAEKJOON

1676 팩토리얼 0의 개수

JH_ 2022. 7. 14. 21:39

📖 question

https://www.acmicpc.net/problem/1676

 

1676번: 팩토리얼 0의 개수

N!에서 뒤에서부터 처음 0이 아닌 숫자가 나올 때까지 0의 개수를 구하는 프로그램을 작성하시오.

www.acmicpc.net

 

✍️ answer

n = int(input())
result = 1
count = 0
for i in range(1, n+1):
    result *= i

result = str(result)

for j in reversed(result):
    if j == '0':
        count += 1
    else:
        break
print(count)