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

~60s

Trailing zeros in 100!

How many zeros does 100! end with?

Show the answer and the worked solution

Correct answer: B.

24

Worked solution

  1. Trailing zeros = number of factors of 5 in 100! (there are always more 2s than 5s).
  2. Multiples of 5 up to 100: ⌊100/5⌋ = 20. Multiples of 25 contribute one more each: ⌊100/25⌋ = 4. Multiples of 125: 0.
  3. 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.

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.

Question

How many zeros does 100! end with?

Options

  1. 20
  2. 24
  3. 25
  4. 30
Show the answer and the worked solution

Correct answer: B. 24

Worked solution

  1. Trailing zeros = number of factors of 5 in 100! (there are always more 2s than 5s).
  2. Multiples of 5 up to 100: ⌊100/5⌋ = 20. Multiples of 25 contribute one more each: ⌊100/25⌋ = 4. Multiples of 125: 0.
  3. 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.

All Number System questions · placement mock tests