confusion with modulo

Revision en1, by PROGRAMMAR, 2017-07-09 00:06:57

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.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English PROGRAMMAR 2017-07-09 00:11:50 43
en2 English PROGRAMMAR 2017-07-09 00:09:17 50
en1 English PROGRAMMAR 2017-07-09 00:06:57 453 Initial revision (published)