Page not loading? Try clicking here.
Placeholder

#6266

팩토리얼의 합의 마지막 수 1s 32MB

Problems

1! + 2! + 3! + \dots + n! 의 마지막 자리의 숫자(1의 자릿수)는 얼마인가?

여기서 n! = 1 \times 2 \times 3 \times \dots \times n이다. 즉, n!1부터 n까지 모든 자연수의 곱이다.

예를 들어, 5! = 1 \times 2 \times 3 \times 4 \times 5 = 120 이다.


Input

첫 줄에 정수 n이 주어진다. (1 \le n \le 1,000,000,000)


Output

첫 줄에 정답에 해당하는 정수를 출력한다.


Example #1

1
1

Example #2

2
3

Source

KOI 시도예선 수학 2013 중고등부 1번

You must sign in to write code.