Tuesday, September 16, 2014

Factorial


Problem

Idea : Given an integer n , you have to find out number of zeros at the end of n! .

There are one zero at the end of a number x . What is its meaning ? That means , x can be expressed as multiple of 10(5*2) . Similarly , There are two zero at the end of a number x . What is its meaning ? That means , x can be expressed as multiple of 10(5*2)*10(5*2) . If we want to count the number of zero , we should count the number of 5*2 appears in the number . The number of zero is equal to the number of 5*2 .

To do so , we first look up at 5 and 2 . How many 5 and 2 is in the number .

As example , if n=10

Number of 5 = 10/5 = 2
Number of 2 = 10/2 = 5

We see that , the number of 2 > the number of 5 .

So , cheaking 5 is enough .

In an integer n , number of 5 is n/5 .

Some numbers have two , three or more munber of 5 as 25 , 50 , 75 , 100

So , we can cheak in n the total occurance of 5 by -

Single 5 = n/5
Double 5 = n/25
Triple 5 = n/75 and so on......

The total number of 5 = The total number of 5*2 = The total number of zero .


 My Solution


1 comment:

  1. factorial hundred In the last few days, the “factorial of 100” is one of the top subjects and a lot of maths geeks compute it using voice assistants such as Alexa, Shiri, etc.
    factorial hundred In the last few days, the “factorial of 100” is one of the top subjects and a lot of maths geeks compute it using voice assistants such as Alexa, Shiri, etc.

    ReplyDelete