Trailing zeros in 100! — Number System Aptitude Question
Trailing zeros in 100!: How many zeros does 100! end with? Answer and worked solution on CodeKairo.
- Topic: Number System
- Section: Quantitative Aptitude
- Difficulty: Medium
- Time target: 60 seconds
Question
How many zeros does 100! end with?
Options
- 20
- 24
- 25
- 30
Show the answer and the worked solution
Correct answer: B. 24
Worked solution
- Trailing zeros = number of factors of 5 in 100! (there are always more 2s than 5s).
- Multiples of 5 up to 100: ⌊100/5⌋ = 20. Multiples of 25 contribute one more each: ⌊100/25⌋ = 4. Multiples of 125: 0.
- Total = 20 + 4 = 24.
Answer: 24.
The idea
Zeros at the end of n! = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …, stopping when the power of 5 exceeds n. The same idea (Legendre's formula) counts any prime's power in a factorial.
Shortcut. Zeros in n! = (n − sum of n's digits in base 5) ÷ 4. 100 is 400 in base 5, digit sum 4, so (100 − 4) ÷ 4 = 24.
Common trap. 20 — stopping at ⌊100/5⌋ and missing the extra five in each of 25, 50, 75 and 100.