Theorem (Legendre)
Let p be a prime number and let n∈N.
Then
vp(n!)=k=1∑∞⌊pkn⌋,
where vp(m) denotes the exponent of p in the prime factorization of the positive integer m.
Proof
For every positive integer m, let vp(m) denote the unique non-negative integer satisfying
pvp(m)∣m,pvp(m)+1∤m.
Since
n!=i=1∏ni,
the uniqueness of prime factorization implies
vp(n!)=i=1∑nvp(i).(1)
Therefore, it suffices to compute the right-hand side.
For each positive integer i, observe that
vp(i)=k=1∑∞1pk∣i,(2)
where
1pk∣i={1,0,if pk∣i,otherwise.
Indeed, if vp(i)=e, then
p,p2,…,pe
divide i, whereas
pe+1,pe+2,…
do not divide i.
Hence exactly the first e terms of the series (2) are equal to 1, and every remaining term is 0.
Therefore,
k=1∑∞1pk∣i=e=vp(i).
Substituting (2) into (1) yields
vp(n!)=i=1∑nk=1∑∞1pk∣i.(3)
Since
1pk∣i=0whenever pk>n,
every summand in (3) is eventually zero.
Consequently, the double sum contains only finitely many non-zero terms, so the order of summation may be exchanged:
vp(n!)=k=1∑∞i=1∑n1pk∣i.(4)
Fix k≥1.
The inner sum
i=1∑n1pk∣i
counts precisely the integers
i∈{1,…,n}
that are divisible by pk.
Such integers are exactly
pk,2pk,3pk,…,⌊pkn⌋pk,
and there are
⌊pkn⌋
of them.
Hence
i=1∑n1pk∣i=⌊pkn⌋.(5)
Substituting (5) into (4), we obtain
vp(n!)=k=1∑∞⌊pkn⌋.
Finally, if
k>logpn,
then pk>n, and therefore
⌊pkn⌋=0.
Thus only finitely many terms of the series are non-zero, so the above expression is well defined.
This completes the proof.
□