AI InterviewSearch…Search problems, topics, or pages…Ctrl KGet started
Mediumfactorialtrailing zeros

~60s

Trailing zeros in 125!

How many zeros are there at the end of 125!?

Show the answer and the worked solution

Correct answer: C.

31

Worked solution

  1. ⌊125/5⌋ = 25
  2. ⌊125/25⌋ = 5
  3. ⌊125/125⌋ = 1
  4. 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).

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.

Question

How many zeros are there at the end of 125!?

Options

  1. 25
  2. 28
  3. 31
  4. 36
Show the answer and the worked solution

Correct answer: C. 31

Worked solution

  1. ⌊125/5⌋ = 25
  2. ⌊125/25⌋ = 5
  3. ⌊125/125⌋ = 1
  4. 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).

All Number System questions · placement mock tests