Trailing Zeros in Factorial: Formula, Tricks and Examples
Trailing Zeros in Factorial means the zeroes at the end of the decimal form of n!. The count depends on the number of pairs of factors 2 and 5 in the factorial. Since factors of 2 are more frequent, the answer is found by counting factors of 5 using successive powers of 5.
What Are Trailing Zeros in a Factorial?
Each trailing zero requires one factor pair of 2 × 5 = 10. For a positive integer n, the count is obtained by adding the multiples of 5, 25, 125 and higher powers of 5 that are not greater than n. For example, 25! has 5 + 1 = 6 trailing zeros.
Trailing Zeros in Factorial Formula & Tricks
Important Formulas
Continue adding terms while 5^k ≤ n. Each term counts the contribution of factors of 5 from multiples of that power.
A zero requires one factor 2 and one factor 5. Since v₂(n!) is greater than v₅(n!), the number of zeros equals the total exponent of 5.
Quick Tricks
Count every multiple of 5 once, every multiple of 25 an additional time, every multiple of 125 another time, and so on.
Numbers such as 25, 125 and 625 contain more than one factor of 5. Their extra factors must be counted through successive powers of 5.
Trailing Zeros in Factorial Concepts
Why factors of 5 determine the zeros
In n!, factors of 2 are more numerous than factors of 5 because every second number contributes a factor of 2, while only every fifth number contributes a factor of 5. Therefore, the smaller exponent, v₅(n!), determines the number of trailing zeros.
Legendre method for n!
The required calculation is ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + ... . Stop when the next power of 5 is greater than n. The first term counts multiples of 5, while later terms count extra factors from multiples of 25, 125 and higher powers.
Extra factors from powers of 5
The first division by 5 counts such numbers once. Dividing by 25, 125 and higher powers counts their additional factors of 5. This prevents undercounting in factorials containing powers of 5.
Finding the smallest n for a required number of zeros
The function Z(n) = ⌊n/5⌋ + ⌊n/25⌋ + ... is non-decreasing. For example, 24! has 4 zeros, while 25! has 6 zeros, so 25 is the smallest n for at least 6 trailing zeros.
Trailing Zeros in Factorial Video Lessons
Watch short topic-wise lessons for quick revision.
Factorials: Trailing Zeros and Prime Powers
Learn how to find trailing zeros in factorials and determine the highest power of a prime that divides a factorial using standard number system methods.
Practice Trailing Zeros in Factorial Questions
Practise published questions related to this topic.
Trailing Zeros in Factorial Quick Quiz
Attempt 5 questions and check your score instantly.
Keep practising
Practice more Trailing Zeros in Factorial questions in the PrepShots app and continue from your current topic.
Practice More Questions - Start ₹1 Trial →Quick Revision Notes
Trailing Zeros in Factorial: Quick Revision
Use these rules to calculate trailing zeros in n! quickly and accurately.
- A trailing zero is formed by one pair of factors 2 and 5.
- For n!, factors of 2 exceed factors of 5, so count the factors of 5.
- Formula: Z(n!) = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + ... .
- Continue until the power of 5 becomes greater than n.
- Multiples of 25, 125 and higher powers contribute extra factors of 5.
- For 100!, Z(100!) = 20 + 4 = 24.
- For 125!, Z(125!) = 25 + 5 + 1 = 31.
Trailing Zeros in Factorial FAQs
What is the formula for trailing zeros in n!?
The formula is Z(n!) = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + ... . Add terms until 5^k exceeds n.
How many trailing zeros does 100! have?
Z(100!) = ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24. Therefore, 100! has 24 trailing zeros.
How many trailing zeros does 50! have?
Z(50!) = ⌊50/5⌋ + ⌊50/25⌋ = 10 + 2 = 12. Hence, 50! has 12 trailing zeros.
Why are multiples of 25 counted twice?
Every multiple of 25 contains at least two factors of 5. The division by 5 counts one factor, and the division by 25 counts its additional factor.
How many trailing zeros are in 125!?
Z(125!) = ⌊125/5⌋ + ⌊125/25⌋ + ⌊125/125⌋ = 25 + 5 + 1 = 31.
What is the smallest n for which n! has at least 6 trailing zeros?
The smallest value is n = 25. Since Z(24!) = 4 and Z(25!) = 5 + 1 = 6, 25! is the first factorial with at least 6 trailing zeros.
