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 20000000! my question why & how 100000000000(10^11) is safe as modulo? 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.