Legendre's formula explained

In mathematics, Legendre's formula gives an expression for the exponent of the largest power of a prime p that divides the factorial n!. It is named after Adrien-Marie Legendre. It is also sometimes known as de Polignac's formula, after Alphonse de Polignac.

Statement

For any prime number p and any positive integer n, let

\nup(n)

be the exponent of the largest power of p that divides n (that is, the p-adic valuation of n). Then

\nup(n!)=

infty
\sum
i=1

\left\lfloor

n
pi

\right\rfloor,

where

\lfloorx\rfloor

is the floor function. While the sum on the right side is an infinite sum, for any particular values of n and p it has only finitely many nonzero terms: for every i large enough that

pi>n

, one has

style\left\lfloor

n
pi

\right\rfloor=0

. This reduces the infinite sum above to

\nup(n!)=

L
\sum
i=1

\left\lfloor

n
pi

\right\rfloor,

where

L=\lfloorlogpn\rfloor

.

Example

For n = 6, one has

6!=720=243251

. The exponents

\nu2(6!)=4,\nu3(6!)=2

and

\nu5(6!)=1

can be computed by Legendre's formula as follows:

\begin{align} \nu2(6!)&=

infty
\sum
i=1

\left\lfloor

6
2i

\right\rfloor=\left\lfloor

6
2

\right\rfloor+\left\lfloor

6
4

\right\rfloor=3+1=4,\\[3pt] \nu3(6!)&=

infty
\sum
i=1

\left\lfloor

6
3i

\right\rfloor=\left\lfloor

6
3

\right\rfloor=2,\\[3pt] \nu5(6!)&=

infty
\sum
i=1

\left\lfloor

6
5i

\right\rfloor=\left\lfloor

6
5

\right\rfloor=1. \end{align}

Proof

Since

n!

is the product of the integers 1 through n, we obtain at least one factor of p in

n!

for each multiple of p in

\{1,2,...,n\}

, of which there are

style\left\lfloor

n
p

\right\rfloor

. Each multiple of

p2

contributes an additional factor of p, each multiple of

p3

contributes yet another factor of p, etc. Adding up the number of these factors gives the infinite sum for

\nup(n!)

.

Alternate form

One may also reformulate Legendre's formula in terms of the base-p expansion of n. Let

sp(n)

denote the sum of the digits in the base-p expansion of n; then

\nup(n!)=

n-sp(n)
p-1

.

For example, writing n = 6 in binary as 610 = 1102, we have that

s2(6)=1+1+0=2

and so

\nu2(6!)=

6-2
2-1

=4.

Similarly, writing 6 in ternary as 610 = 203, we have that

s3(6)=2+0=2

and so

\nu3(6!)=

6-2
3-1

=2.

Proof

Write

n=n\ellp\ell++n1p+n0

in base p. Then

style\left\lfloor

n
pi

\right\rfloor=n\ellp\ell-i++ni+1p+ni

, and therefore

\begin{align} \nup(n!) &=

\ell
\sum
i=1

\left\lfloor

n
pi

\right\rfloor\\ &=

\ell
\sum
i=1

\left(n\ellp\ell-i++ni+1p+ni\right)\\ &=

\ell
\sum
i=1
\ell
\sum
j=i

njpj-i\\ &=

\ell
\sum
j=1
j
\sum
i=1

njpj-i\\ &=

\ell
\sum
j=1

nj

pj-1
p-1

\\ &=

\ell
\sum
j=0

nj

pj-1
p-1

\\ &=

1
p-1
\ell
\sum
j=0

\left(njpj-nj\right)\\ &=

1
p-1

\left(n-sp(n)\right). \end{align}

Applications

Legendre's formula can be used to prove Kummer's theorem. As one special case, it can be used to prove that if n is a positive integer then 4 divides

\binom{2n}{n}

if and only if n is not a power of 2.

It follows from Legendre's formula that the p-adic exponential function has radius of convergence

p-1/(p-1)

.

References