# How to find the rightmost 25 digits in $100!$?

The question is

Find the rightmost 25 digits in decimal expansion of $100!=1\times 2\times \dotsb \times100$

By counting the number of fives in the prime factorisation of $100!$, I know there are $\lfloor {100 \over 5} \rfloor + \lfloor {100 \over {5^2}} \rfloor =24$ trailing zeros.

But I am really stuck with finding the remaining 25th digit, could someone help me please?

• – lab bhattacharjee Aug 16 '15 at 6:09
• @labbhattacharjee I see. But I can't really list 1 to 100 as the first answer did to 1 to 30. – Rescy_ Aug 16 '15 at 6:34
• – lab bhattacharjee Aug 16 '15 at 6:37

For $\prod_{r=1}^{10}(10a+r)\equiv\prod_{r=1}^{10}r\pmod5$

Now if we exclude the multiples of $5,$ which have been consumed in forming $24$ trailing zeros

$1\cdot2\cdot3\cdot4\cdot6\cdot7\cdot8\cdot9\cdot2\equiv2\pmod5$

$\prod_{a=0}^9\left(\prod_{r=1}^{10}(10a+r)\right)\equiv\left(\prod_{r=1}^{10}r\right)^{10}\pmod5\equiv2^{10}\equiv2^2\equiv4$

Now $2^{24}$ have been consumed in forming $24$ trailing zeros

As $2^4\equiv1\pmod5,2^{24}\equiv1^6\equiv1$

So, the last non-zero digit in $100!$ will be $4\cdot1^{-1}\equiv4\pmod5\ \ \ \ (1)$

and it is already $0\pmod2\ \ \ \ (2)$

Using Chinese Remainder Theorem on $(1),(2)$

or by observation as $x\equiv4\pmod5\implies x\equiv4,4+5\pmod{}10,$

the last non-zero digit in $100!$ will be $4\pmod{10}$

• @achillehui, Thanks for your observation. I also, found the mistake while taking bath! – lab bhattacharjee Aug 16 '15 at 7:41

Just figured out this myself.

It is easy to determine that there are 24 trailing zeros, so the only thing left is to determine $\frac{100!}{10^{24}}\pmod {10}$

Writing the fraction as $$\frac{(1 \cdot 3 \cdot 7 \cdot 9 \ \dotsc \cdot 99)(5 \cdot 10 \cdot 15 \cdot \dotsc \cdot 100)(2 \cdot 4 \cdot 6 \cdot 8 \cdot \dotsc \cdot 98) }{10^{24}} \equiv \frac{(1 \cdot 3 \cdot 7 \cdot 9)^{10} \cdot 5^{20} \cdot(1 \cdot 2 \cdot 3 \cdot \dotsc \cdot 20) \cdot 2^{40} \cdot (1 \cdot 2 \cdot 3 \cdot 4)^{10} }{5^{24} \cdot 2^{24}}\equiv \frac{(9)^{10} \cdot(1 \cdot 2 \cdot 3 \cdot \dotsc \cdot 20) \cdot 6 \cdot (4)^{10} }{5^{4}} \equiv 1 \cdot (1 \cdot 2 \cdot 3 \cdot 4)^4 \cdot 6 \cdot 6 \equiv 4$$

So the 25th digit is 4.