Trailing zeros in 125! — Number System Aptitude Question
Trailing zeros in 125!: How many zeros are there at the end of 125!? Answer and worked solution on CodeKairo.
- Topic: Number System
- Section: Quantitative Aptitude
- Difficulty: Medium
- Time target: 60 seconds
Question
How many zeros are there at the end of 125!?
Options
- 25
- 28
- 31
- 36
Show the answer and the worked solution
Correct answer: C. 31
Worked solution
- ⌊125/5⌋ = 25
- ⌊125/25⌋ = 5
- ⌊125/125⌋ = 1
- Total = 25 + 5 + 1 = 31.
Answer: 31.
The idea
Trailing zeros of n! = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …, stopping when the power of 5 passes n. Candidates who stop after the first term get 25, which is why it is offered.
Shortcut. Zeros in n! = (n − sum of n's digits in base 5) ÷ 4. 125 is 1000 in base 5, digit sum 1, so (125 − 1) ÷ 4 = 31.
Common trap. 25 — stopping at ⌊125/5⌋ and forgetting the extra five in each multiple of 25 (five more) and the third five in 125 (one more).