Finding the right most non zero digit of a factorial

Suppose,we are asked to find the last non zero digit of 100!, How do we find it?

We know that the number of zeros at the end of 100! is 24.  Our task is to find the leading digit from the right.
Before that, we will see some interesting observations.
100! = 1 × 2 × 3 × 4 × 5 × ........× 99 × 100

Let us write the above format like below
= (5 × 10 × 15 ×......× 95 × 100) × (1 × 2 × 3 × 4 ) × (6 × 7 × 8 × 9) × (11 × 12 × 13 × 14) × (16 × 17 × 18 × 19 ) × ............ × (91 × 92 × 93 × 94) × (96 × 97× 98 × 99)
= (1 × 5) × (2 × 5) × (3 × 5) ×......× (20 × 5) × (1 × 2 × 3 × 4 ) × (6 × 7 × 8 × 9) × (11 × 12 × 13 × 14) × (16 × 17 × 18 × 19 ) × ............ × (91 × 92 × 93 × 94) × (96 × 97× 98 × 99)

By taking 5's common and multiplying the remaining terms,
520 × 20! × (1 × 2 × 3 × 4) × (6 × 7 × 8 × 9) × (11 × 12 × 13 × 14) × (16 × 17 × 18 × 19 ) × ............ × (91 × 92 × 93 × 94) × (96 × 97 × 98 × 99)

You can see the black terms gives units digits of 2 if we divide it by 2

Proof: 
Let us consider (10a + 1)(10a + 2)(10a + 3)(10a +4)
This expression is a generalized format of the terms (1 × 2 × 3 × 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 × (10a + 1)(5a +1) (10a + 3) (10 a + 4)
2 × (50a2 + 15a + 1)(100a2 +70 a + 12)
2 × (5000a4 + 3500a3 + 600a2 + 1500a3 + 1050a2 + 180a + 100a2 + 70a + 12)
Each term contains zero except the last term. So after pulling one 2 out, unit digit of the remaining expression is 2.

Similarly, (10a + 6)(10a + 7)(10a + 8)(10a + 9)
By pulling out one 2 and multiplying the remaining terms gives us,

2 × (5a + 3)(10a + 7) (10 a + 8) (10 a + 9)
2 × (50a2  + 65a + 21)(100a2  +170 a + 72)
2 × (5000a4 + 8500a3 + 3600a2 + 6500a3 + 11050a2 + 4680a + 2100a2 + 3570a + 1512)
Each term contains zero except the last term. So after pulling one 2 out, unit digit of the remaining expression is 2.

Therefore, unit digit of 100! = 520 x 20! x (2 x 2) x (2 x 2) x ......20 times = 520×20!×220×220=1020×20!×220

So unit digit of 100! = Unit digit of 20!×220

From the above discussion leading non zero digit of 100 ! = [1005]!×2(100/5)=20!×220

Applying the above logic, the last non zero digit of 20! = [205]!×2(20/5)=4!×24

So Last non zero digit of 100! = (20!×220)=(4!×24)×220
= 24 x 16 x 6 = 4


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 28!
In this case we consider the leading non zero digit upto 25 and manually we multiply the units digits of the remaining 3 terms with the result.
25! = 55×5!×25×25105×5!×25
So the unit digit of 25! = 120 x 32 = 4 (We omit the zero)
Now unit digit of 28! = 4 x 26 x 27 x 28 = 4

The generalized formula to find the non zero digit of N = [N5]!×2[N/5]×[N5]Rem!
Here [ ] denotes greatest integer function.  [3.6] = 3 and rem means remainder when N is divided by 5.

3. Find the last non zero digit of 2000! 
We know that Last non zero digit of 2000! = [20005]!×2(2000/5)=(400!×2400)
Again Last non zero digit of 400! = [4005]!×2(400/5)=(80!×280)
Again last non zero digit of 80! = [805]!×2(80/5)=(16!×216)

Now 16! = [165]!×2[16/5]×[165]Rem! = 3!×23×1!=8

Now combining the whole discussion last non zero digit of 2000! = 2400×280×216×8 = 6 x 6 x 6 x 8 = 8

No comments:

Post a Comment