Number Theory

How to find Last Non Zero Digit in a Factorial

3 min read

Advertisement

In this post, we will have a look at the techniques to calculate the Right Most Non Zero Digit in a Factorial. In one of our previous posts we explained a technique to calculate the highest power of a number in a factorial. This post deals with calculating the last non-zero digit in a factorial.

At the end of this post you will be able to solve problems like

  • How to calculate the last non zero digit in 20 factorial.
  • How to find the last non zero digit in 96 factorial.
  • Find the last non zero digit of 658! etc.

We will solve these problems by first looking into a conventional approach and then with the help of formula that can help us in calculating the right most non-zero digit of any factorial.

How to find the last non-zero digit of n!?

We will look into two approaches here:

Approach 1: The logical multiplication approach

  1. We first express the factorial as a product.
  2. Then, since we are calculating the right most non-zero digit, we ignore those numbers whose product will result in multiple of 10. To do this we ignore the pairs of 5 and 2 whose product will lead to 10
  3. Multiply the units digit from the rest of the numbers

Calculate the right most non zero digit in 5!

  1. Here 5! = 5 x 4 x 3 x 2 x 1.
  2. In the product, there is one pair of 5 and 2. Ignoring this pair we get: 4 x 3 x 1
  3. Units digit in 4x3x1 is 2 which is the right most non zero digit of 5!

Find the last non zero digit in 15!

Here 15! = 15 x 14 x 13 x 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1

Advertisement

Now in 15!,

  1. There are 3 pairs of 5 and 2. Ignoring these we get: 3x7x13x12x11x9x8x7x6x2x3x2x1
  2. Now, just multiply the units digit of the numbers successively:

3×7 = 21 => Multiply 1 in 21 with 3 in 13 => 1×3 = 3 => 3 x 2 (2 in 12) => 6 => 6 x 1 (1 in 11) => 6 x 9 => 4 (4 in 54) x 8 => 2 (2 in 32) x 7 => 4 (4 in 14) x 6 => 4 (4 in 24) x 2 => 8 x 3 => 4 (4 in 24) x 2 = 8

Hence the last non zero digit in 15! is 8.

As you can see from the above approach, this can be quite time consuming as the number becomes larger. A simpler approach would be using a formula as described below:

Approach 2: Using a formula

If n is expressed as $5a + b$, then the right most non zero digit of n! is given by

$L(n!)$ = $Last$ $Digit$ $of$ $[ 2^a$ x $L(a!)$ x $L(b!) ]$

How to calculate the last non zero digit in 20 factorial

Here n is 20. Expressing 20 in terms of 5a+b, we have

20 = 5*4+0. i.e a=4 and b=0.

L(20!) = Last Digit of [ 24 x L(4!) x L(0!) ]

Last digit of 24 = 6

L(4!) = Last non zero digit of 4x3x2x1 = 4

Thus, L(20!) = Last Digit of [ 6 x 4 x 1 ] = 4

Find the last non zero digit of 50!

Here n is 50. 50 in terms of 5a+b = 5*10+0. i.e a = 10 and b = 0

L(50!) = Last Digit of [ 210 x L(10!) x L(0!) ]

Last digit of 210 = Units digit of 210 = Units digit of 22 = 4

To calculate L(10!)

10 = 5×2 + 0 => a = 2, b = 0

L(10!) = Last digit of [ 22 x L(2!) x L(0!) ] = Last digit of [ 4 x 2 x 1] = 8

Thus, L(50!) = Last Digit of [ 210 x L(10!) x L(0!) ] = Last Digit of [4 x 8 x 1] = 2

How to find the last non zero digit in 96 factorial

n = 96. Expressing 96 in terms of 5a+b, we have

96 = 5*19+1. i.e a=19 and b=1.

L(96!) = Last Digit of [ 219 x L(19!) x L(1!) ]

Calculating the last digit of 219. Using the technique explained in this post : Units digit of 219 => Units digit of 23 = 8

Next lets calculate L(19!).

Again expressing 19 in terms of 5a + b, we have

19 = 5×3 + 4.

Thus L(19!) = Last Digit of [ 23 x L(3!) x L(4!) ]

Last digit of 23 = 8.

Right most non zero digit of L(3!) = 3×2 = 6

Last non zero digit of L(4!) = 4x3x2 = 4.

Hence L(19!) = Last digit of [8 x 6 x 4] = 2

Now, getting back to our original problem

L(96!) = Last Digit of [ 219 x L(19!) x L(1!) ]

Last digit of 219 = 8

L(19!) = 2

L(1!) = 1

Thus L(96!) = Last Digit of [ 8 x 6 x 1 ] = 6


What Next?

Advertisement

Leave a Reply

Your email address will not be published. Required fields are marked *

four × three =