Skip to main content
MBA Compass Logo
MBA Compassby B School Buzz
arithmetic

Legendre's formula: Exponent of a prime p in n!

intermediate
High weightage
CAT
XAT
NMAT
SNAP
CMAT
IIFT
MAT
\displaystyle v_{p}(n!)=\sum_{k=1}^{\infty} \left\lfloor \frac{n}{p^{k}} \right\rfloor
This formula gives the exponent n!) of a prime p in the prime factorization of n! (n factorial), where n is a nonnegative integer and p is prime. Variables: n (integer, np (prime), n!) is nonnegative integer count of times p divides n!. The sum counts how many multiples of p, are present among factors 1n; each multiple of contributes at least one additional p factor. Algebraically it telescopes the valuation of factorial. Edge cases: terms become zero when n so the sum is finite in practice. For p>n the exponent is zero. Use integer division (floor).

Related formulas