Maths & numbers

Factorial trailing zeros calculator

Count factors of ten in a factorial without expanding the product.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

There are more factors of 2 than 5 in a factorial, so the factors of 5 determine the number of final decimal zeros.

THE FORMULASum floor(n/5ᵏ) for positive k

A worked example

100! has 20 multiples of 5 plus four additional factors from multiples of 25.

Good to know

This counts zeros in base ten.

Count the factors of five in the factorial

A trailing decimal zero requires a factor of 10, or one factor each of 2 and 5. In a factorial, factors of 2 occur at least as often as factors of 5, so fives limit the count. For 100!, the multiples of 5 contribute 20 factors.

The multiples of 25 contribute an additional four fives because each contains at least 5². There are no multiples of 125 below 100. Adding the counts gives floor(100/5) + floor(100/25) = 20 + 4 = 24 trailing zeros. The number 25 is counted in both groups deliberately because it contributes two separate factors of five.

One hundred factorial has twenty factors of five from multiples of five and four additional ones from multiples of twenty-five⌊100/5⌋ = 20+⌊100/25⌋ = 424 factors of 5 → 24 trailing zeros
Each multiple of 25 contributes an extra factor of 5. Twenty plus four gives 24 trailing decimal zeros.

Do not count only visible multiples of ten

A factor of 10 can be formed by different factorial terms. In 5!, the separate factors 2 and 5 already produce one trailing zero even though none of the terms is 10. Counting only terms that end in zero would miss that contribution.

The Prime exponent in a factorial calculator generalizes the same repeated-division formula to a chosen prime. For decimal trailing zeros, selecting prime 5 gives the required count. Other numeral bases require balancing the prime factors of their base separately. The input is the factorial argument n, not an already computed factorial. This avoids constructing a huge product solely to inspect its final digits.

A few questions, answered

How many trailing zeros does 0! have?

Zero factorial equals 1, which has no trailing zeros.

Why does the count increase by two at 25?

The new factorial term 25 contributes two factors of five, increasing the zero count by two at once.

Find your calculator

Start typing to explore the library.