04:05

How to find the first Non-zero digit of a factorial?

I mean, how to find Rightmost non-zero digit of n! or R(n!).

let n be the given number.
    R(n!) be the function that will give us right most non-zero digit of n!.


write the given n in the following form:

              n=5*q+r.             

where, q-> quotient
           r-> remainder

              R(n!) = Last Digit of [ 2 qx R(q!) x R(r!) ]           


Some of the factorials we are familiar with are:
0! = 1; 1! = 1; 2! = 2; 3! = 6; 4! = 24; 5! = 120; 6! = 720; 7! = 5040.
let's take an example:
what is first non-zero digit in 18!?

n=18,
it is re-written as 18=5*3+3.

R(18!)=Last Digit of [23xR(3!)xR(3!)]
              =Last Digit of [8x6x6]
              =8.
actual value of 18!=
6402373705728000.

let's take even bigger one.
what is first non-zero digit in 551!?
n=551.
551=5*110+1;
q=110, r=1

R(551!)=Last Digit of [2110xR(110!)xR(1!)]
          
It's a recursive procedure.
110=5x22+0
 R(110!)=Last Digit of [222xR(22!)xR(0!)]

again, 22=5x4+2

R(22!)=Last Digit of [24xR(4!)xR(2!)]
              =Last Digit of [16 x 24 x 2]

              =8.
R(110!)=Last Digit of [222xR(22!)xR(0!)]            
=Last Digit of [222x 8 x 1]
=Last Digit of[4 x 8 x 1]            
=2.

R(551!)=Last Digit of [2
110xR(110!)xR(1!)]
               =Last Digit of [4 x 2 x 1]
               =8.

finally R(551!)=8.    (Is it not smart way of doing it?.)

just remember this,


              R(n!) = Last Digit of [ 2 qx R(q!) x R(r!) ]           
                   



0 comments: