Last non-zero digit of a factorial
Find a method to calculate the last non-zero digit of , where and .
Solution: We have the following formula , where this is proved by removing from terms divisible by .
Since we can obtain the following reccurence , where is the last non-zero digit of and by the integer remainder theorem.
This enables us to calculate the last digit of very fast, descending exponentially at every step to reach small numbers, for which we can easily calculate that digit.