Factorial Fun
n! = 1 × 2 × 3 × . . . × n. Given n, find the last non-zero digit of n!.
InputEach test case consists of a single line containing n, 1<=n<=1 000 000.
OutputFor each test case output a single line with the last non-zero digit of n!.
Sample Input:
Sample Output:
5
Sample Output:
2
Sample Input:
Sample Output:
10
Sample Output:
8
Sample Input:
12
Sample Output:
6
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.