How to find the Trailing Number of Zeros at the End of Product - Experts Advice

Experts Advice

An Advice can change your life!

How to find the Trailing Number of Zeros at the End of Product

Share This

TRAILING NUMBER OF ZEROS

Zeros-at-the-end-of-product

Definition: Trailing Zeros are total number of Zeros at the end of a number.
Example: 
  • 234 has zero trailing number of zeros as it is divisible by 100.
  • 560 has one trailing number of zeros as it is divisible by 101.
  • 3562400000 has 5 trailing number of zeros as it is divisible by 105.
Therefore, if any number is divisible by 10k , then it has k trailing number of zeros.

Do you know how many Zeros are there in 1 Googol?

Zeros are formed by a combination of (2 x 5). Hence the number of zeros depend on no. of pairs of 2's and 5's.
Example: 
  • 22 x 52 = 4 x 25 = 100. There are two trailing number of zeros as there are two pairs of (2 x 5). 
  • 22 x 523 = No need to do such a long multiplication, there will be two trailing number of zeros as there are only two pairs of (2 x 5).
It means when there are both 2's and 5's are present then lowest power of either of them represents the trailing number of zeros.


Number of Zeros at the end of n!

5! = 5 x 4 x 3 x 2 x 1 = 120
It has only one Trailing number of Zero because there is only one pair of (2 x 5). 
But is it possible to expand factorial of big numbers like 100!?

Total-zeros-in-hundred-factorial

It seems impossible manually to multiply such a big number. So we need to calculate pairs of (2x5) only to determine the Trailing number of Zeros.

But we already know that lowest power of either 2 or 5 gives us number of zeros at the end of product and for such a big number we have plenty of 2's. So we need to determine multiple of 5's only.

Formula: [n/5] + [n/52] + [n/53] + ....
The integral value of this sum will be number of zeros.
[n/5]   => The number of multiples of 5 that are less than or equal to n.
[n/52] => The number of multiples of 25 that are less than or equal to n. Each multiple of 25 contributes 1 additional trailing number of zeros as it has two 5's (52).
[n/53] => The number of multiples of 125 that are less than or equal to n. Each multiple of 125 contributes 2 additional trailing number of zeros as it has three 5's (53).
and so on...

Example 1: Find the number of zeros or highest power of 5 in 126!
Solution: No of zeros = [126/5] + [126/52] + [126/53]
               = 25 + 5 + 1 = 31
There will be total 31 Trailing number of zeros at the end of 126!

Example 2: Find the number of zeros at the end of product 1 x 3 x 5 x 7 x....x 1001.
Solution: There will be no trailing number of zeros as there is no even number and there won't be any pair of (2 x 5).

Example 3: Find the number of zeros at the end of product of first 25 Prime numbers?
Solution: The only even prime number is 2, so total number of trailing zeros will be ONE

Special Case:
We can use the above formula to find the highest power of any prime number in n!

Example: Find the highest power of 3 in 38! 
Solution: Highest power = [38/3] + [38/32] + [38/33]
                = 14 + 4 + 1 = 17

Instead of manual calculation or counting number of pairs of (2 x 5) use this formula directly to determine trailing number of zeros at the end of product of numbers. Question can also be asked like find the highest power of given prime number contained in the given number but method will remains same. Good Luck 👍


No comments:

Post a Comment