쏘ing

[Python] 백준 1676 팩토리얼 0의 개수 본문

알고리즘/CLASS 3

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

한민민 2022. 2. 21. 14:59

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

 

풀이 1

num = int(input())

count = 0
temp = 1

# 팩토리얼 값 계산
for i in range (num):
    temp *= (i + 1)

temp = list(map(int, str(temp)))

# 0 개수 찾기
while (temp[-1] == 0):
    count += 1
    temp.pop()
    
print(count)

 

풀이 2

# 5의 개수로 찾기
# 5 제곱은 0의 개수가 두개, 세제곱은 세개 증가하므로 따로 더해줘야 함
num = int(input())
print(num // 5 + num // 25 + num // 125)

 

Comments