Finding the last two non zero digits of a factorial


In the previous article we learnt how to find the last non zero digit of a factorial.  In this lesson we try to learn how to find last two non zero digits of a factorial.
We will take the same example and try to find the last two non zero digit of 100!. In this case we focus on finding the product of last two digits instead of unit digits the way we did to find the last non zero digit.

We try to repeat some part of the lesson from the earlier lesson.
100! = 1 x 2 x 3 x 4 x 5 x ........x 99 x 100

Let us write the above format like below
(5 x 10 x 15 x......x 95 x 100) x (1 x 2 x 3 x 4 ) x (6 x 7 x 8 x 9) x (11 x 12 x 13 x 14) x (16 x 17 x 18 x 19 ) x ............ x (91 x 92 x 93 x 94) x (96 x 97 x 98 x 99)
By taking 5's common and multiplying the remaining terms,
${5^{20}}$ x 20! x (1 x 2 x 3 x 4) x (6 x 7 x 8 x 9) x (11 x 12 x 13 x 14) x (16 x 17 x 18 x 19 ) x ............ x (91 x 92 x 93 x 94) x (96 x 97 x 98 x 99)
Let us consider (10 a + 1)(10 a + 2)(10 a + 3)(10 a +4)
This expression is a generalized format of the terms (1 x 2 x 3 x 4 )
For a = 0 we get the first term in the bracket, for a = 1 we get third term in the bracket

By pulling out one 2 and multiplying the remaining terms gives us,
2 x (10 a + 1)(5a +1) (10 a + 3) (10 a + 4)
2 x (50${a^2}$ + 15a + 1)(100${a^2}$ +70 a + 12)
2 x (5000${a^4}$ + 3500${a^3}$ + 600${a^2}$ + 1500${a^3}$ + 1050${a^2}$ + 180a + 100${a^2}$ + 70a + 12)
2 x (5000${a^4}$ + 5000${a^3}$ + 1750${a^2}$ +250a + 12)
First two terms has more than two zeroes. So last two digits of this expression depends on 1750${a^2}$ +250a + 12

We try to find the last two digits of 1750${a^2}$ +250a.  Taking 250 common
250 x 7${a^2}$ + a) = $2 \times {5^3}(7{a^2} + a)$
Now If a is odd, $7{a^2} + a$ is even so which contributes another 2. So 1750${a^2}$ +250a has two zeroes. If a is even, 1750${a^2}$ +250a clearly gives two zeroes.
So the last two digits after pulling out 2 from the above is 12. 

Similarly, (10 a + 6)(10 a + 7)(10 a + 8)(10 a + 9)
By pulling out one 2 and multiplying the remaining terms gives us,
2 x (5 a + 3)(10a + 7) (10 a + 8) (10 a + 9)
2 x (50${a^2}$ + 65a + 21)(100${a^2}$ +170 a + 72)
2 x (5000${a^4}$ + 8500${a^3}$ + 3600${a^2}$ + 6500${a^3}$ + 11050${a^2}$ + 4680a + 2100${a^2}$ + 3570a + 1512)
2 x (5000${a^4}$ + 15000${a^3}$ + 16750${a^2}$ + 8250a + 1512)
This expression also has last two digits 12 after pulling out 2. 

For example:
11 x 12 x 13 x 14 = 24024 = 2 x 12012
16 x 17 x 18 x 19 = 93024 = 2 x 46512
21 x 22 x 23 x 24 = 255024 = 2 x 127512
Therefore, Last two digits of 100! = ${5^{20}}$ x 20! x (2 x 12) x (2 x 12) x ......20 times = ${5^{20}} \times 20! \times {2^{20}} \times {12^{20}} = {10^{20}} \times 20! \times {12^{20}}$
So last two digits of 100! = last two digits of $20! \times {12^{20}}$

From the above discussion leading two non zero digit of 100 ! = $\left[ {\displaystyle\frac{{100}}{5}} \right]! \times {12^{(100/5)}} = 20! \times {12^{20}}$
Applying the above logic, the last two non zero digit of 20! = $\left[ {\displaystyle\frac{{20}}{5}} \right]! \times {12^{(20/5)}} = 4! \times {12^4}$
So Last non zero digit of 100! = $(20! \times {12^{20}}) = (4! \times {12^4}) \times {12^{20}}$
= ${12^{24}}$ x 4!
= ${4^{24}}$x${3^{24}}$x24
= ${2^{48}}$x${81^{24}}$x24
= ${\left( {{2^{10}}} \right)^4} \times {2^8} \times 81 \times 24$  (if ${2^{10}}$ power is odd we get 24 as the last two digits, if even we get 76 ). Read this article
= 76 x 56 x 81 x 24
= 64

2. How do we proceed If the given number is not divisible by 5 exactly?? For example we have to find the leading  non zero digit of 32!
In this case we consider the leading two non zero digit upto 30 and manually we multiply the last two digits of the remaining 2 terms with the result.
30! = ${5^6} \times 6! \times {12^6} \times {2^6} \Rightarrow {10^6} \times 6! \times {12^6}$
So the last two digits of 30! = 720 x ${12^3}$ x ${12^3}$ = 72 x 28 x 28 = 48 (We omit the zero)
Last two digits of 32! = 48 x 31 x 32 = 16

The generalized formula to find the last two non zero digits of N = $\left[ {\frac{N}{5}} \right]! \times {12^{\left[ {N/5} \right]}} \times $ Last two digits of the remaining terms.
Here [ ] denotes greatest integer function.  [3.6] = 3