View Code of Problem 3801

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

#define MAX(a,b) (a)>(b)?(a):(b);
#define MAXN 10010
typedef long long ll;

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int ans=1;
        for(int i=1;i<=n;i++)
        {
             ans=ans*i;
             while(ans%10==0)
                ans/=10;
             ans%=10;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 3801