#include<bits/stdc++.h>usingnamespace std;constint MOD =1e9;intmain(){int n;
cin >> n;longlong fac =1;for(int i =1; i <= n; i++){
fac *= i;while(!(fac %10)) fac /=10;
fac %= MOD ;}
cout << fac%10<< endl;return0;}
//我们进行观察,因为0只可能由2的倍数和5的倍数相乘得到,//所以在进行乘法的过程中,我们将2和5的倍数给清理掉,这样//就保证了不会出现0,然后我们控制其范围,每次相乘取其个//位,因为个位肯定是非零元素,十位以后的数字完全没有必//要保留下来,最后,我们将多处理的2或者5重新乘回去再取余即可。#include<iostream>#include<cstring>#include<algorithm>usingnamespace std;intmain(){int n;
cin >> n;int c =1, d2 =0, d5 =0;for(int i =1; i <= n; i ++){int x = i;while(x %2==0) x /=2, d2 ++;while(x %5==0) x /=5, d5 ++;
c = c * x %10;}for(int i =0; i < d2 - d5; i ++)
c = c *2%10;
cout << c << endl;return0;}
#include <bits/stdc++.h>using namespace std;const int MOD = 1e9;int main() { int n; cin >> n; long long fac = 1; for(int i = 1; i <= n; i++) { fac *= i; while(!(fac % 10)) fac /= 10; fac %= MOD ;