#P2529. Last Non-Zero Digit of Factorial
Last Non-Zero Digit of Factorial
Last Non-Zero Digit of Factorial
In this problem, you are given a positive integer n. You must compute the last non-zero digit of n! (i.e. the factorial of n) in its decimal representation.
Recall that the factorial is defined as (n! = 1 \times 2 \times 3 \times \cdots \times n). In order to avoid the trailing zeros produced by the factors of 10, you should remove all factors of 10 during the multiplication process, and finally output the last non-zero digit of the resulting product.
inputFormat
The input consists of a single integer n (1 \leq n \leq 1000).
outputFormat
Output the last non-zero digit of n!.
sample
1
1