Last non-zero digit of nPm

Revision en2, by snorkel, 2021-04-20 02:35:22

Trying to solve this problem. I got the last non-zero digit by working with $$$2$$$-s and $$$5$$$-s, but here's an easier solution by using $$$10$$$ directly.

Can anyone explain why this works? How taking modulo $$$10^9$$$ does not make it wrong?

Code

Thanks.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English snorkel 2021-04-20 02:35:22 215
en1 English snorkel 2021-04-20 02:13:42 720 Initial revision (published)