Factorial Trailing Digits

For any $N$, let $f(N)$ be the last five digits before the trailing zeroes in $N!$.
For example,

$9! = 362880$ so $f(9)=36288$
$10! = 3628800$ so $f(10)=36288$
$20! = 2432902008176640000$ so $f(20)=17664$
Find $f(1\,000\,000\,000\,000)$.

The problem at hand expects to find out the last five digits (ignoring trailing zeros) of the factorial of 1,000,000,000,000 ($10^{12}$).

However, it’s important to note that this problem isn’t feasible to solve directly since calculating the factorial of such a large number is computationally intensive and would require immense computational power and time.

Still, we can approach this problem using the concept of number theory, specifically modular arithmetic. Modular arithmetic deals with integers and their equivalence when divided by a certain modulus to yield the same remainder.

For this problem, we want to find the last five digits, or the remainder when divided by $10^5 = 100000$, ignoring trailing zeros. This equates to finding the remainder when divided by $2^5 * 5^5 = 32 * 3125 = 100000$.

Thus, we need to find the product $1 * 2 * 3 * … * 10^{12}$ modulo $2^5 * 5^5$.

When any number is multiplied by 10, it will add a trailing zero to the product, so we need to exclude multiples of 10 from the product. The way to do this is by finding f($10^{12}$) eqv. to $1 * 2 * 3 * … * 9 * 11 * 12 * … * 19 * 21 * … * 10^{12}$ modulo $2^5 * 5^5$.

So our problem of finding $f(10^{12})$ transforms into finding $f(1), f(2), …, f(10^{12}/10)$ being multiplied and the product modulo $2^5 * 5^5$.

If we keep expanding as above, we notice a pattern that repeat after every 10 steps, so we just need to calculate the repeating unit and then raise it to power $10^{12}/10 = 10^{11}$ modulo $2^5 * 5^5$.

Once we figure out the pattern and calculate the repeating unit, the problem simplifies to applying Fermat’s Little Theorem and the Chinese Remainder Theorem.

This isn’t a trivial mathematical exercise and would need advanced understanding of number theory.

Moreover, it’s noteworthy to mention that even with this reduction-specific approach, calculations become extremely tricky and non-trivial, which still require advanced algorithms and more manageable number sizes. It’s not exactly solvable by hand or by using simple calculator.

This is an example of problems that mathematicians and programmers are often challenged to solve using mathematical theory and optimization strategies.

If you’re intrigued by such problems, I would suggest studying number theory, modular arithmetic, Euler’s totient theorem, Fermat’s little theorem, and principles of mathematical algorithms further to get deeper understanding and ability to approach such problems.

More Answers:
Base-10 Diophantine Reciprocal
Lexicographical Neighbours
Digital Root Sums of Factorisations

Error 403 The request cannot be completed because you have exceeded your quota. : quotaExceeded

Share:

Recent Posts

Don't Miss Out! Sign Up Now!

Sign up now to get started for free!