Factorial Values and Number of Trailing Zeros in a Factorial
Quantitative Aptitude › Number System · Topic 1.7
The factorial of a natural number n, written n!, is the product of all natural numbers from 1 to n, and 0! is defined as 1. The number of trailing zeros in n! equals the highest power of 5 dividing n!, found by adding the quotients n/5, n/25, n/125 and so on.
5 min read · Quantitative Aptitude · Number System
Quick Answer
The factorial of a natural number n, written n!, is the product of all natural numbers from 1 to n, and 0! is defined as 1. The number of trailing zeros in n! equals the highest power of 5 dividing n!, found by adding the quotients n/5, n/25, n/125 and so on.
At a Glance
- n! 1 × 2 × 3 … × n
- 0! 1
- Trailing zeros in n! n/5 + n/25 + n/125 + … (whole parts)
- Reason Each zero needs one 2 and one 5
- Limiting factor The power of 5
- Zeros in 100! 24
Where Does It Fit?
This topic follows Prime Numbers, Composite Numbers and Co-Prime Numbers and uses prime factors. It leads to Number of Trailing/Leading Zeros in the Product of Consecutive Numbers on zeros in products and to Highest Power of a Prime Number Dividing a Factorial, which generalises the method to any prime.
What Is a Factorial and What Are Its First Values?
In short: n! multiplies every whole number from 1 up to n.
| n | n! |
|---|---|
| 0 | 1 |
| 1 | 1 |
| 2 | 2 |
| 3 | 6 |
| 4 | 24 |
| 5 | 120 |
| 6 | 720 |
| 7 | 5,040 |
| 8 | 40,320 |
| 9 | 3,62,880 |
| 10 | 36,28,800 |
- Recursive form: n! = n × (n – 1)!, so 6! = 6 × 120 = 720.
- Zero factorial: 0! = 1 by convention, which keeps formulas such as combinations consistent.
- Growth: factorials grow very fast. 10! already ends with two zeros.
How Do You Count the Trailing Zeros in n!?
In short: a trailing zero comes from a factor 10 = 2 × 5. In n! there are many more 2s than 5s, so the number of zeros equals the number of 5s in its prime factors.
Zeros in n!
- Zeros = floor(n/5) + floor(n/25) + floor(n/125) + … until the quotient is 0.
- Floor means the whole-number part of the division.
| n | Working | Zeros |
|---|---|---|
| 24 | 4 | 4 |
| 25 | 5 + 1 | 6 |
| 50 | 10 + 2 | 12 |
| 100 | 20 + 4 | 24 |
| 125 | 25 + 5 + 1 | 31 |
| 200 | 40 + 8 + 1 | 49 |
| 500 | 100 + 20 + 4 | 124 |
| 1,000 | 200 + 40 + 8 + 1 | 249 |
The extra step at 25, 125 and so on appears because 25 contributes two 5s, and 125 contributes three. Here the idea is the same as in Highest Power of a Prime Number Dividing a Factorial, where any prime is used instead of 5.
How Do You Find n for a Given Number of Zeros?
In short: trailing zeros jump at multiples of 5, so a given count is reached by five consecutive values of n, or by none.
- The count of zeros is 9 for n = 40 to 44, then 10 for n = 45 to 49. So the smallest n with exactly 10 zeros is 45, and there are five such values: 45, 46, 47, 48, 49.
- Some counts never occur. The count jumps from 4 at n = 24 to 6 at n = 25, so no factorial has exactly 5 trailing zeros.
- To find n for a count, multiply the count by about 4 (since n/5 + n/25 + … is close to n/4) and check the multiples of 5 near that value; for 10 zeros, start near 40 and check 45.
Solved Examples
Example 1
Question: How many trailing zeros does 100! have?
- floor(100/5) = 20.
- floor(100/25) = 4.
- floor(100/125) = 0, so stop. Total = 20 + 4.
Answer: 24 zeros.
Example 2
Question: Find the number of trailing zeros in 125!.
- floor(125/5) = 25.
- floor(125/25) = 5.
- floor(125/125) = 1. Total = 25 + 5 + 1.
Answer: 31 zeros.
Example 3
Question: Find the smallest n such that n! ends in exactly 10 zeros.
- Try n = 40: 8 + 1 = 9 zeros.
- Try n = 45: 9 + 1 = 10 zeros.
- n = 44 gives 8 + 1 = 9, so 45 is the smallest.
Answer: n = 45.
Example 4
Question: How many trailing zeros does 1,000! have?
- floor(1000/5) = 200.
- floor(1000/25) = 40, and floor(1000/125) = 8.
- floor(1000/625) = 1. Total = 200 + 40 + 8 + 1.
Answer: 249 zeros.
Shortcuts and Tricks
- Divide repeatedly by 5 and add the quotients; ignore remainders.
- Count only the 5s, since 2s are always more plentiful.
- For counts that skip, remember that jumps happen at 25, 50, 75 and so on, with bigger jumps at 25 and 125.
- A quick estimate is n/4, and the exact value is just below it.
- Use 5! = 120 and 10! = 36,28,800 as anchors.
Common Mistakes
- Forgetting the extra 5s in 25, 125 and 625.
- Counting the number of multiples of 10 instead of multiples of 5.
- Including remainders in the division steps.
- Saying 0! = 0. It equals 1.
- Stopping after the first division by 5.
Practice Questions
- How many trailing zeros does 50! have?
- How many trailing zeros does 200! have?
- How many trailing zeros does 500! have?
- How many trailing zeros does 24! have?
- How many trailing zeros does 26! have?
- What is 8! ?
Answers: 1) 12; 2) 49; 3) 124; 4) 4; 5) 6; 6) 40,320.
Why Is This Topic Important?
- Common Trailing-zero questions appear in many aptitude papers.
- Concept They test prime factors of factorials in a short formula.
- Link Extends to any prime in Highest Power of a Prime Number Dividing a Factorial.
- Link to counting Factorials are the base of Fundamental Principle of Counting (Addition and Multiplication Rules).
What Comes Next?
The next topic is Remainder Theorem and Chinese Remainder Theorem, which studies remainders and the Chinese Remainder Theorem.
Key Terms and Formulas
- Factorial Product of 1 to n
- Trailing zeros Zeros at the end of a number
- Floor Whole part of a quotient
- Power of 5 Number of 5s in the prime factors
- Legendre formula Sum of floor(n/pk)
- 0! 1
Related Topics
- Prime Numbers, Composite Numbers and Co-Prime Numbers
- Remainder Theorem and Chinese Remainder Theorem
- Classification of Numbers (Natural, Whole, Integers, Rational, Irrational and Real Numbers)
- Face Value and Place Value of Digits
Exam Corner
Points to Remember
- Trailing zeros in n! = floor(n/5) + floor(n/25) + floor(n/125) + …
- Zeros in 100! are 24 and in 1,000! are 249.
- 0! = 1.
- No factorial has exactly 5, 11, 17 or 23 zeros, since counts jump over these values.
- Five consecutive values of n share each possible zero count.
Do Not Confuse With
- Zeros in n! vs zeros in n Count the 5s in the product, not the zeros in the number n.
- n! vs n n! multiplies all numbers up to n.
- Power of 5 vs power of 2 The 5s are fewer, so they limit the zeros.
- floor vs rounding Floor drops the remainder.
Memory Hook
Divide by 5, 25, 125 and add the whole parts.
GS Relevance
Frequently Asked Questions
What is the formula for trailing zeros in n factorial?
The number of trailing zeros in n factorial is the sum of the whole parts of n divided by 5, n divided by 25, n divided by 125, and so on until the quotient becomes zero. For 100 factorial this gives 20 plus 4, which is 24 trailing zeros.
Why do trailing zeros depend on the number of 5s?
Each trailing zero comes from a factor of 10, which is 2 times 5. A factorial contains many more 2s than 5s in its prime factorization, so the number of 5s limits the number of tens. Therefore the number of trailing zeros equals the highest power of 5 in the factorial.
What is the value of 0 factorial?
The value of 0 factorial is 1 by convention. This definition keeps formulas for permutations and combinations consistent, because there is exactly one way to arrange zero objects. For example, the combination of n things taken n at a time equals n factorial divided by n factorial times 0 factorial, which is 1.
How many trailing zeros does 1000 factorial have?
The number 1000 factorial has 249 trailing zeros. The count adds the whole parts of 1000 divided by 5, 25, 125 and 625, which are 200, 40, 8 and 1. The quotient for 3125 is zero, so the sum stops there at 249.
Can a factorial have exactly 5 trailing zeros?
No factorial has exactly 5 trailing zeros, because the count jumps from 4 at 24 factorial to 6 at 25 factorial. At 25 the number gains two factors of 5, so the number of trailing zeros increases by 2 and skips the value 5.
PYQ Practice — Statement Analysis
1 0! equals 0.
By definition 0! = 1.
2 The number of trailing zeros in 100! is 24.
20 + 4 = 24.
3 Exactly five values of n give 10 trailing zeros in n!.
The values are 45, 46, 47, 48 and 49.
4 Some factorial has exactly 5 trailing zeros.
The count jumps from 4 at 24! to 6 at 25!.
Related Topics
Browse the full Quantitative Aptitude index