Java 代码
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int num = cin.nextInt();
int result = 1 ;
int MOD = 1000000;
for (int i = 1; i <= num; i++ )
{
result *= i;
while (result % 10 == 0)
{
result = result/10 ;
}
result %= MOD;
}
System.out.println(result % 10);
}
}