long long ans=1;
for(int i=1; i<=20000000; i++)
{
ans*=i;
while(ans%10==0)
ans/=10;
ans%=100000000000LL;
}
cout<<ans%10<<endl;
####
This is a code of finding the last-non-zero-digit of factorial(20000000) my question why & how 10^11 is safe as modulo in this case? shouldn't it be at least 10^15? since 19999998 * 19999999 = 399999940000002 which is greater than 10^11. please clear it to me. Thanks in advance.