A zero at the end of a number comes from a factor of 10 = 2 × 5. So the number of trailing zeros of n! equals the number of complete (2, 5) pairs in its prime factors.

Even numbers appear every second step, but multiples of 5 only every fifth step, so n! always has more twos than fives. The fives run out first, and the count of fives is the count of zeros.

Some numbers carry more than one five: 25 = 5 × 5 carries two, 125 carries three. That gives the standard formula, where each term is the whole-number part of the division:

Zeros in n! = n/5 + n/25 + n/125 + n/625 + …

Stop when the divisor is larger than n.

Worked example 1: 100!

100/5 = 20 and 100/25 = 4. 125 is larger than 100, so stop. 100! ends in 24 zeros.

Worked example 2: 250!

250/5 = 50, 250/25 = 10, 250/125 = 2. Total 62 zeros.

Worked example 3: 1000!

200 + 40 + 8 + 1 (from 625) = 249 zeros.

A shortcut: divide n by 5, then divide the answer by 5 again, and keep going, adding the whole-number results. For 1000: 200, 40, 8, 1, giving 249. It is the same calculation, done in a chain.

To check an answer, remember that the count grows by one with each new multiple of 5 and by two at each multiple of 25. So 99! and 100! differ by 2 zeros, because 100 is a multiple of 25, while 104! and 105! differ by only 1.

The same idea works for any prime p (this is often called Legendre's formula):

Highest power of p in n! = n/p + n/p² + n/p³ + …

Worked example 4: power of 3 in 50!

50/3 = 16, 50/9 = 5, 50/27 = 1, and 81 > 50. The highest power of 3 dividing 50! is 3²².

For a composite number, split it into primes, count each prime in n!, and take the limiting one.

Worked example 5: power of 6 in 30!

6 = 2 × 3. 30! has 15 + 7 + 3 + 1 = 26 twos and 10 + 3 + 1 = 14 threes. Each 6 needs one of each, so the threes limit it: 6¹⁴.

Worked example 6: power of 12 in 40!

12 = 2² × 3. 40! has 38 twos, enough for 19 copies of 2², and 13 + 4 + 1 = 18 threes. The smaller figure wins: 12¹⁸. Remember to divide the count by the exponent when a prime appears squared.

When the product skips numbers, the twos are no longer guaranteed to outnumber the fives. Count both.

Worked example 7: 5 × 10 × 15 × … × 100

There are 20 terms, each 5 times a number from 1 to 20, so the product is 5²⁰ × 20!. Fives: 20 + 4 = 24. Twos come only from 20!: 10 + 5 + 2 + 1 = 18. The twos run out first, so the product ends in 18 zeros, not 24.

The same care is needed for products such as 1 × 3 × 5 × … (all odd), which have no twos at all and so no trailing zeros, however many fives they contain.

Because multiples of 25 add two fives at once, some zero counts never occur.

Worked example 8: is there an n! with exactly 5 zeros?

24! has 4 zeros, but 25! jumps to 6 (5 + 1). No factorial ends in exactly 5 zeros. Factorials from 25! to 29! all end in 6 zeros.

  • Stopping at n/5. Always add n/25, n/125 and higher terms while they are at least 1.
  • Using decimals. Each term is a whole-number part; 60/25 counts as 2, not 2.4.
  • Assuming twos are plentiful in any product. That holds for factorials only.
  • Forgetting the exponent. For 12 = 2² × 3, halve the count of twos.
  • Answering with the limiting prime's partner. The smaller count decides.

For counting divisors, see number of factors.

Q1. How many zeros are there at the end of 60!? easy

✅ Answer: (b) 14

💡 Explanation: 60 ÷ 5 = 12 and 60 ÷ 25 = 2 (whole parts), so 60! ends in 12 + 2 = 14 zeros.

Q2. How many trailing zeros does 125! have? medium

✅ Answer: (a) 31

💡 Explanation: 125/5 = 25, 125/25 = 5 and 125/125 = 1. Total 31. Forgetting the 125 term gives 30.

Q3. What is the highest power of 7 that divides 100!? medium

✅ Answer: (d) 16

💡 Explanation: Count multiples of 7 (14) and of 49 (2): 14 + 2 = 16. 343 is larger than 100, so stop there.

Q4. How many zeros does 500! end with? easy

✅ Answer: (c) 124

💡 Explanation: 500/5 = 100, 500/25 = 20, 500/125 = 4, and 625 > 500. Total 124.

Q5. What is the highest power of 15 that divides 50!? hard

✅ Answer: (b) 12

💡 Explanation: 15 = 3 × 5. 50! has 22 threes but only 12 fives, so at most 12 copies of 15 can be formed.

Why do we count only fives and not twos?

Each trailing zero needs one 2 and one 5. A factorial has far more even factors than multiples of 5, so the fives always run out first and decide the count.

Why divide by 25 as well as 5?

A multiple of 25 such as 50 contributes two fives (50 = 2 × 5 × 5), but dividing by 5 counts it only once. Dividing by 25 picks up the second five, by 125 the third, and so on.

Is there a number with exactly 5 zeros at the end of its factorial?

No. 24! ends in 4 zeros and 25! jumps to 6, because 25 adds two fives at once. Counts like 5, 11 and 17 are skipped in the same way.

All problems and solutions on this page are original. No outside facts are relied on; every numeric answer is recomputed by software before publishing.

How this page was prepared. Drafted with AI assistance (Claude (Anthropic AI model)) from the sources listed above. 14 calculations on this page were recomputed by software and matched. Automated checks also covered structure, internal links and duplicate text. Software checks cannot confirm facts.

Found an error? Report it and we will correct the page.