math
라이브러리에 있는factorial
을 이용해서 팩토리얼 값을 구한 다음 0이 아닌 가장 낮은 수를 구해주었다.
import math
import sys
input = sys.stdin.readline
N = int(input())
res = str(math.factorial(N))
while True:
res = res[::-1]
for i in res:
if i == "0":
continue
else:
print(i)
sys.exit(0)