Maths & numbers

Prime exponent in a factorial calculator

Count the multiplicity of a chosen prime in a factorial.

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

Multiples of p² contribute to both the first and second counts. This is how their two factors of p are recorded.

THE FORMULAvₚ(n!) = Σ floor(n/pᵏ)

A worked example

25! contains 8 + 2 = 10 factors of 3.

Good to know

The selected divisor must be prime.

Count each occurrence of the chosen prime

For 25! and prime 3, eight terms are multiples of 3. Two of those terms, 9 and 18, are also multiples of 9 and contribute an additional factor of 3 each. No term reaches 27. The total exponent is floor(25/3) + floor(25/9) = 8 + 2 = 10.

This is Legendre’s formula, vₚ(n!) = Σ floor(n/pᵏ). Each term counts factorial factors divisible by another power of p. A number divisible by p³ appears in the first three counts because its factorization supplies three copies of p.

The exponent of three in twenty-five factorial is eight plus two⌊25/3⌋ = 8+⌊25/9⌋ = 2v₃(25!) = 10
Eight factorial terms are multiples of 3. Two of those are also multiples of 9 and contribute another 3 each.

Require a prime for this formula

The chosen divisor must be prime. Entering 4 would make the repeated-division sum an invalid way to count factors of 4. For example, 6! contains four factors of 2, giving two factors of 4, whereas floor(6/4) alone gives one. The calculator rejects a composite divisor.

The Factorial trailing zeros calculator specializes the formula to prime 5 because factors of 2 are plentiful in a decimal factorial. The same valuation counts can inspect divisibility of binomial coefficients: subtract the valuations of k! and (n − k)! from the valuation of n!. This is an integer-exponent calculation, so it avoids the large intermediate factorial values.

A few questions, answered

What if the chosen prime exceeds n?

No factorial term is divisible by that prime, so the exponent is zero.

What does an exponent of ten mean?

The factorial is divisible by p¹⁰ but not by p¹¹ for the selected prime p.

Find your calculator

Start typing to explore the library.