Zeroes at the end of a FACTORIAL

  • Thread starter murshid_islam
  • Start date
  • Tags
    Factorial
In summary, we can find the number of zeros at the end of n! by counting the number of times 5 is a prime factor in the natural numbers up to n. In the example of 100!, there are 20 zeros because 100 has 20 factors of 5. However, we must also consider the numbers that are divisible by 25, 125, and so on, adding an additional 4 zeros in the case of 100!. In general, we can use the formula C = [n/5] + [n/5^2] + [n/5^3] + ... + [n/5^q] to determine the number of zeros at the end of n!, where q is
  • #1
murshid_islam
457
19
how can i find the number of zeroes at the end of 100!
how can i find the number of zeroes at the end of n!

thanks in advance.
 
Physics news on Phys.org
  • #2
murshid_islam said:
how can i find the number of zeroes at the end of 100!
how can i find the number of zeroes at the end of n!

thanks in advance.

Your question is the same as finding out how often 5 is a prime factor on the natural numbers.

So I am guessing that 100! has 20 zeros, because in counting by fives, we get to 100 after 20 steps.
 
Last edited:
  • #3
SteveRives said:
Your question is the same as finding out how often 5 is a prime factor on the natural numbers.

So I am guessing that 100! has 20 zeros, because in counting by fives, we get to 100 after 20 steps.
You are WRONG, SteveRives.
24 zeros is the answer.
(*)You will have a number which is divisible by 5 for every 5 successive integer.
(*)You will have a number which is divisible by 25 (ie 5.5) for every 25 successive integer.
(*)You will have a number which is divisible by 125 (ie 5.5.5) for every 125 successive integer, and so on...
So you will have 20 numbers which is divisible by 5 (included numbers that is divisible by 25).
And you will have 4 numbers which is divisible by 25.
So you will have: 20 + 4 = 24 zeros in 100!
In general, you will have: n! has:
[tex]C = \left[ \frac{n}{5} \right] + \left[ \frac{n}{5 ^ 2} \right] + \left[ \frac{n}{5 ^ 3} \right] + ... + \left[ \frac{n}{5 ^ q} \right][/tex] zeros at the end.
You can stop the sum at any q such that:
[tex]\left[ \frac{n}{5 ^ q} \right] = 0[/tex]
Where [...] denotes the integer part of a number. For example : [1.55] = 1, [0.77] = 0, [14.333333] = 14.
Viet Dao,
 
Last edited:
  • #4
Yes, I just realized that we have to add four more! Why? Because in 20 steps, there are four times that five is reduplicated.

Finding the number of times 5 is a prime factor is right, but, for example, when we get to 25 it is in there twice. And so 20 / 5 is 4. There are four times that happens. Add that back into the 20 and we get 24.
 
  • #5
The formula given in this thread is inaccurate. It's not the rounding function, but the floor function that should be used.

floor(n/5)+floor(n/(52))+floor(n/(53))+...

This is because rounding each quotient may occasionally result in counts that are too high. For example: 999!

999/5=199.8~200 (correct value: 199)
999/25=39.96~40 (correct value: 39)
999/125=7.992~8 (correct value: 7)
999/625=1.5984~2 (correct value: 1)
Total: 250 (correct value: 246)

As you can see, there's an error of 4 zeros!

Edit: Never mind. I misinterpreted his symbols. The Rounding function is usually indicated by square brackets. The Floor, or the integer part of the number, is indicated by L-shaped brackets. So naturally without reading the entire post, I jumped to a conclusion.
 
Last edited:
  • #6
for writing a program it may be useful to get the number of zeros at the end of a factorial without usage of floor function:

n = p(1)*5 + q(1)

p(1) = p(2)*5 + q(2)
p(2) = p(3)*5 + q(3)

etc

p(n-1) = p(n)*5 + q(n)

so,

p(n) = (p(n-1) - q(n))/5
p(n-1) = (p(n-2) - q(n-1))/5

etc

where q(i) is actually p(i-1) mod 5 , or q(i) = p(i-1)%5
 
  • #7
You provided the easiest solution.

One 5 each from 5,10,15,20,30,35,40,45,55...70,80,85…
(excluded 25,50,75,100) so that's 15x1=15

Two 5s each from 25,50,100
Three 5s from 75

15+2x3+3x1=24

It was an easy problem. Why did I think its tough :/
Thanks for answering, everyone.
 
  • #8
This thread is 7 years old.
 

What is a factorial?

A factorial is a mathematical operation in which a number is multiplied by all the numbers below it. For example, the factorial of 5 (written as 5!) is equal to 5 x 4 x 3 x 2 x 1 = 120.

Why do zeroes appear at the end of a factorial?

Zeroes appear at the end of a factorial because the numbers in the multiplication sequence include factors of 5 and 2. When these factors are multiplied together, they result in a zero at the end of the number.

How can I determine the number of zeroes at the end of a factorial?

The number of zeroes at the end of a factorial can be determined by counting the number of multiples of 5 in the factorial's number. For example, in 10!, there is one multiple of 5 (5), which means there is one zero at the end of the number. In 25!, there are two multiples of 5 (5 and 25), which means there are two zeroes at the end of the number.

Is there a limit to the number of zeroes at the end of a factorial?

Yes, there is a limit to the number of zeroes at the end of a factorial. The maximum number of zeroes at the end of a factorial is equal to the number of multiples of 5 in the factorial's number. For example, in 120!, there are six multiples of 5 (5, 10, 15, 20, 25, and 30), so there can be a maximum of six zeroes at the end of the number.

How can I write a factorial without any zeroes at the end?

To write a factorial without any zeroes at the end, you can rearrange the numbers in the multiplication sequence to ensure that there are no factors of 5 or 2. For example, instead of writing 10! as 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1, you can write it as 10 x 9 x 8 x 7 x 6 x 3 x 4 x 2 x 5 x 1. This will result in a factorial with no zeroes at the end.

Similar threads

  • Linear and Abstract Algebra
Replies
6
Views
1K
  • Linear and Abstract Algebra
Replies
8
Views
915
  • Precalculus Mathematics Homework Help
Replies
25
Views
1K
Replies
2
Views
710
Replies
10
Views
1K
  • Mechanical Engineering
Replies
6
Views
900
  • General Math
Replies
3
Views
1K
Replies
8
Views
2K
  • Linear and Abstract Algebra
Replies
14
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
281
Back
Top