2! = 2

3! = 6

4! = 24

5! = 120

6! = 720

7! = 5040

8! = 40320

9! = 362880

10! = 3628800

Maybe you can remember till here. But what if you are asked for last non zero digit in 75! or maybe last two non-zero digits in 124! or more…you need a generic concept to deal with these domain on problems.

**Concept of last non-zero digit in n factorial**

5! = 120

Let us take 20! for our discussion.

20! = [1 * 2 * 3 * 4 * 5] * [6 * 7 * 8 * 9 * 10] * [11 * 12 * 13 * 14 * 15] * [16 * 17 * 18 * 19 * 20]

If you look at the last non zero digits of each of these brackets individually you will not the following pattern

[2 * 1] * [2 * 2] * [2 * 3] * [2 * 4]

In general, each bundle of 5 consecutive number starting from 5n + 1 form to 5(n + 1) form gives the last non-zero digit as 2 multiplied by the (n + 1).

So for 21 [=5(4) + 1] to 25 [=5(4 + 1)], we will have 2 * 5.

Their composite product’s last non-zero digit will be the last non zero digit of n factorial.

Hence, for 20! , we will have 2^4 * (1 * 2 * 3 * 4) = 2^4 * 4! = 16 * 24 = 6 * 4 = 24 => Answer: 4

In general, last non zero digit of n factorial is given by last non zero of 2^a * a! * b! Where n = 5a + b

Example : Find the last non-zero digit of 33!

33 = 5(6) + 3

Last non zero digit = 2^6 * 6! * 3! = 4 * 2 * 6 = 8 [See how only unit digits were taken for faster calculation]

**Concept of last two non-zero digits in n factorial**

Why did we had 2*(n + 1) for each bundle of 5?

Because 5! has its last non-zero digit as 2.

So following the same principle you will realize that last two non-zero digits of n factorial can also be easily found out by simply writing n = 5a + b and then the last two non-zero digits of n factorial will be given by 12^a * a! * (5a + 1) * (5b + 2). . * (5a + b)

Example : Find the last two non-zero digits of 84!

84 = 5(16) + 4

Last two non-zero digits = 12^16 * 16! * 81* 82 * 83 * 84

How to calculate further would be the question in your mind. So let’s clear the air on that before we go ahead.

Part I: You will need to re-apply the formula on 16!

16 = 5(3) + 1

12^3 * 3! * 16

28 * 6 * 16

28 * 96

88 [Note we just need the last two non-zero digits so you may not calculate the whole products]

Part II: Last two digits of 12^n

12^2 = 44; 12^4 = 36; 12^6 = 84

Use them repeatedly to get close to your value. 12^16 = (12^4)^4 = 36^4 = 96^2 = 16

Part III: Calculating residual numbers’ product that were didn’t come up in bundles of 5.

Product of four consecutive numbers starting from either (10k + 1) or (10k + 6) form will always end in 24.

So, 81 * 82 * 83 * 84 ends in 24.

Then you do 88 * 16 * 24 for last two digits of your 84!

For product of three consecutive residual numbers we calculate as follows

Example : 56 * 57 * 58 = (57 – 1)(57)(57 + 1) = 57(57^2 – 1) = 47 * (49 – 1) = 47 * 48 = 56 (last two digits)

**Last three non-zero digits and more**

Example : Find the last three non-zero digits of 12!

Just form bundles of 5 and consider last three digits in all your multiplications.

12 = 5(2) + 2

12^2 * 2! * 11 * 12 = 288 * 132 = 016

NOTE: This method gives you the last three non-trailing non-zero digits. If a zero occurs in expression of n factorial besides the ending part, it will not neglect that. You know how you would go about it even if gets further which would be a rare occurrence actually

]]>2! = 2

3! = 6

4! = 24

5! = 120

6! = 720

7! = 5040

8! = 40320

9! = 362880

10! = 3628800

Maybe you can remember till here. But what if you are asked for last non zero digit in 75! or maybe last two non-zero digits in 124! or more…you need a generic concept to deal with these domain on problems.

**Concept of last non-zero digit in n factorial**

5! = 120

Let us take 20! for our discussion.

20! = [1 * 2 * 3 * 4 * 5] * [6 * 7 * 8 * 9 * 10] * [11 * 12 * 13 * 14 * 15] * [16 * 17 * 18 * 19 * 20]

If you look at the last non zero digits of each of these brackets individually you will not the following pattern

[2 * 1] * [2 * 2] * [2 * 3] * [2 * 4]

In general, each bundle of 5 consecutive number starting from 5n + 1 form to 5(n + 1) form gives the last non-zero digit as 2 multiplied by the (n + 1).

So for 21 [=5(4) + 1] to 25 [=5(4 + 1)], we will have 2 * 5.

Their composite product’s last non-zero digit will be the last non zero digit of n factorial.

Hence, for 20! , we will have 2^4 * (1 * 2 * 3 * 4) = 2^4 * 4! = 16 * 24 = 6 * 4 = 24 => Answer: 4

In general, last non zero digit of n factorial is given by last non zero of 2^a * a! * b! Where n = 5a + b

Example : Find the last non-zero digit of 33!

33 = 5(6) + 3

Last non zero digit = 2^6 * 6! * 3! = 4 * 2 * 6 = 8 [See how only unit digits were taken for faster calculation]

**Concept of last two non-zero digits in n factorial**

Why did we had 2*(n + 1) for each bundle of 5?

Because 5! has its last non-zero digit as 2.

So following the same principle you will realize that last two non-zero digits of n factorial can also be easily found out by simply writing n = 5a + b and then the last two non-zero digits of n factorial will be given by 12^a * a! * (5a + 1) * (5b + 2). . * (5a + b)

Example : Find the last two non-zero digits of 84!

84 = 5(16) + 4

Last two non-zero digits = 12^16 * 16! * 81* 82 * 83 * 84

How to calculate further would be the question in your mind. So let’s clear the air on that before we go ahead.

Part I: You will need to re-apply the formula on 16!

16 = 5(3) + 1

12^3 * 3! * 16

28 * 6 * 16

28 * 96

88 [Note we just need the last two non-zero digits so you may not calculate the whole products]

Part II: Last two digits of 12^n

12^2 = 44; 12^4 = 36; 12^6 = 84

Use them repeatedly to get close to your value. 12^16 = (12^4)^4 = 36^4 = 96^2 = 16

Part III: Calculating residual numbers’ product that were didn’t come up in bundles of 5.

Product of four consecutive numbers starting from either (10k + 1) or (10k + 6) form will always end in 24.

So, 81 * 82 * 83 * 84 ends in 24.

Then you do 88 * 16 * 24 for last two digits of your 84!

For product of three consecutive residual numbers we calculate as follows

Example : 56 * 57 * 58 = (57 – 1)(57)(57 + 1) = 57(57^2 – 1) = 47 * (49 – 1) = 47 * 48 = 56 (last two digits)

**Last three non-zero digits and more**

Example : Find the last three non-zero digits of 12!

Just form bundles of 5 and consider last three digits in all your multiplications.

12 = 5(2) + 2

12^2 * 2! * 11 * 12 = 288 * 132 = 016

NOTE: This method gives you the last three non-trailing non-zero digits. If a zero occurs in expression of n factorial besides the ending part, it will not neglect that. You know how you would go about it even if gets further which would be a rare occurrence actually

]]>