Final Report
2008-2009 SAIF Research Project
How Many Zeros Are at the End of a Factorial on Any Base?
by
Mu-Ling Chang
Department of Mathematics
1
Result
The purpose of this reseach was to study the number of zeros at the
end of a factorial on any base. I am glad to report that I have solved the
problem completely and written a research paper “How Many Zeros Are
at the End of a Factorial on Any Base?” which is as follows. I also wrote
another article “The Zero-at-the-end Problem” which has been submitted
to the Journal Math Horizontal. The research results were presented at
UWP Research Poster Day 2009 and at the Mathematical Association of
America Wisconsin Section Meeting 2009 at UW- La Crosse. After my talk
at La Crosse, an audience who was Professor Joyati Debnath (an organizer
of MathFest) invited me to give a presentation at MathFest in Portland,
Oregon in August. This is a great honor to me and to my department
because MathFest is a national conference. Therefore, I am pleased and
proud to say that this research project is a significant success.
2
Introduction
Let n be a positive integer. The notation n!, which is called the n
factorial, denotes the product of the first n positive integers. For example,
5! = 1 · 2 · 3 · 4 · 5 = 120. It is obvious that there is only one zero at the
end of this number. How many zeros are at the end of 5! on a base which
is not 10? If we consider the base 2, the binary expansion (or the base
2 expansion) of 5! is (1111000)2 , and there are three zeros at the end. In
general, given a positive integer n (usually a huge number like 99999), can
we find an effective way to determine the number of zeros at the end of n!
on any base without multiplying it out?
The key to solving this problem is to find the prime factorization of
n!, that is, to rewrite n! as the product of powers of distinct primes. The
definition of a prime is a positive integer greater than 1 that is only divisible
by 1 and itself. For instance, 2, 3, 5, and 7 are primes. Therefore, the
prime factorization of 5! is 23 · 3 · 5. Finding the prime factorizations of
integers is always challenging work which involves the existence of primes.
For example, the integer 87173993000 = 23 · 53 · 8741 · 9973 where both 8741
and 9973 are primes [3, pp. 543, 544] which cannot be factored any more.
From Legendre’s Theorem [2], I will get the prime factorization of n!. Then
by using the exponents of powers in this prime factorization, I am able to
calculate the number of zeros at the end of n! on any base.
3
Main Theorems
By rewriting Legendre’s Theorem, I obtain the following theorem which
gives me the prime factorization of n!.
Theorem 3.1. Let n be a positive integer, and let p1 , p2 , · · · , ps be all distinct primes less than or equal to n. Then
n! = p1 α1 p2 α2 · · · ps αs
where for i = 1, 2, · · · , s, we have
· ¸ · ¸
·
¸
n
n
n
+
αi =
+ ··· +
pi
pi 2
p i λi
such that λi is a positive integer satisfying pi λi ≤ n < pi λi +1 and the notation
[ ] stands for the greatest integer function.
This is a very powerful theorem. In the Introduction, I mentioned that
the prime factorization of 87173993000 is 23 · 53 · 8741 · 9973. What about
87178291200? Since there is only a four-digit difference between these two
numbers, we may guess that the prime factorization of the second one probably also contains some big primes. This time our instinct leads us to the
wrong conclusion because the second number is 14!. By the theorem we will
have
87178291200 = 211 · 35 · 52 · 72 · 11 · 13,
(1)
and the only primes we use in this prime factorization are the ones less than
14. What a fascinating result!
One direct application of this theorem is to determine the number of
zeros at the end of n! (on base 10). This number equals the exponent of
the biggest power of 10 that divides n!. Note that 10 = 2 · 5 and we have
more 2’s dividing n! than 5’s, so the number of zeros is the exponent of the
biggest power of 5 dividing n!.
Corollary 3.2. Let n be a positive integer. The number of zeros at the end
of n! on base 10 is 0 if n < 5; otherwise, it is
· ¸
· ¸ · ¸
n
n
n
+ 2 + ··· + λ
5
5
5
where 5λ ≤ n < 5λ+1 for some positive integer λ.
£ ¤
For example, the number of zeros at the end of 14! is 14
= 2 since
5
5 ≤ 14 < 52 . Without multiplying 14! out to get 87178291200, we are able
to find out how many zeros are at the end of this huge integer. What about
finding the number of zeros at the end of 14! on some base other than 10?
It is obvious that, by (1), the numbers of zeros at the end of 14! are 11, 5,
2, 2, 1, and 1 on base 2, 3, 5, 7, 11, and 13, respectively. Also, no zeros
end in 14! on all other prime bases. What if the base is not just a prime,
for instance, it is a power of a prime, then what should we do? Because of
Corollary 3.2, some people may have a “solution” as follows for this case.
Conjecture Let p be a prime, and let both n and β be positive integers.
The number of zeros at the end of n! on base pβ is 0 if pβ - n!; otherwise, it
is
· ¸ ·
¸
·
¸
n
n
n
+
+ ··· +
pβ
(pβ )2
(pβ )λ
where (pβ )λ ≤ n < (pβ )λ+1 for some positive integer λ.
This conjecture is obtained by mainly replacing 5 by pβ in Corollary 3.2.
Well, is it correct? Let’s consider the case of 6! (= 24 · 32 · 5 = 720) on
base 8. If this conjecture £is ¤correct, we will have no zeros at the end of 6!
on base 8 since 8| 6! and 86 = 0. But the octal expansion (i.e. the base
8 expansion) of 6! is (1320)8 , hence there should be one zero at the end.
Therefore the conjecture is wrong. So how do we get that one zero ending
in 6! on base 8? To do so, let’s take a look at the binary expansion of 6!,
which is (1011010000)2 . This means that 6! can be written as
1 · 29 + 0 · 28 + 1 · 27 + 1 · 26 + 0 · 25 + 1 · 24 + 0 · 23 + 0 · 22 + 0 · 21 + 0 · 20 .
With this information, to get the octal expansion of 6!, we just need to group
every three consecutive terms from the right and factor out the smallest
power of 8, that is,
1 · 29 + (0 · 28 + 1 · 27 + 1 · 26 ) + (0 · 25 + 1 · 24 + 0 · 23 )+
(0 · 22 + 0 · 21 + 0 · 20 )
= 1 · 29 + (0 · 22 + 1 · 2 + 1) · 26 + (0 · 22 + 1 · 2 + 0) · 23 +
(0 · 02 + 0 · 2 + 0) · 20
= 1 · (23 )3 + 3 · (23 )2 + 2 · (23 )1 + 0 · (23 )0
= (1320)8 .
This tells us the connection between the numbers of zeros ending in the
binary and octal expressions of 6!:
Since there are 4 zeros at the end of the binary expression
of 6!, the
£4¤
number of zeros ending in its octal expression should be 3 = 1.
According to this observation, I obtain the following proposition.
Proposition 3.3. Q
Let n and b be positive integers. Suppose the prime factorization of n! is si=1 pi αi where all pi are distinct primes less than or
equal to n, and both s and all αi are positive integers. Then the number of
zeros at the end of n! on base b is 0 if b is divided by a prime greater than
n; otherwise, it is
nh α i h α i
h α io
j1
j2
jk
min
,
,··· ,
β1
β2
βk
if b = pj1 β1 pj2 β2 · · · pjk βk where {j1 , j2 , · · · , jk } ⊆ {1, 2, · · · , s} and all βj are
positive integers.
Proof. Since the first case is obvious, we will prove the second one directly.
By using the assumption that b = pj1 β1 pj2 β2 · · · pjk βk , we have
!µ k
Ã
¶
s
s
Y
Y
Y
αi
αi
α jl
n! =
pi =
pi
pjl
i=1
Ã
i=1
i6=j1 , j2 , ··· , jk
!Ã
s
Y
=
pi
αi
i=1
i6=j1 , j2 , ··· , jk
k
Y
l=1
pjl
αjl −
£ ¤!
£ αj ¤ !Ã Y
k ³
´ αjl
l β
βl
l
β
βl
pjl l
.
l=1
l=1
©£ α ¤ £ α ¤
£ αj ¤ª
Let m = min βj11 , βj22 , · · · , βkk . Then the last equality can be written
as
!m
!Ã k
!Ã k
Ã
£ ¤ !Ã k
s
´ αjl −m
Y
Y αj −£ αjl ¤βl
Y³
Y
β
l
pi αi
pjl l βl
pjl βl
pjl βl
Ã
=
i=1
i6=j1 , j2 , ··· , jk
s
Y
i=1
i6=j1 , j2 , ··· , jk
l=1
!Ã
pi
αi
k
Y
l=1
l=1
!
pjl
αjl −mβl
bm .
l=1
We claim that we cannot factor hout
another factor of b from the middle term
αj i
in the last product. Let m = βkk0 for some k0 ∈ {1, 2, · · · , k}. By the
0
Division Algorithm, we have 0 ≤ αjk0 − mβk0 < βk0 . So the middle term
cannot be divided by pjk0 βk0 , and this completes the proof.
Finally, by combining Theorems 3.1 and Proposition 3.3, we have successfully found a method of determining the number of zeros at the end of
a factorial on any base without multiplying it out. This conclusion is given
as follows.
Theorem 3.4. Let b and n be positive integers. If b is divided by a prime
greater than n, then no zeros end in n!. Otherwise, let b = p1 γ1 p2 γ2 · · · pk γk
where all pi are some distinct primes less than or equal to n, and all γi are
positive integers. Then the number of zeros at the end of n! on base b is
(" Pλ1 £ n ¤ # " Pλ2 £ n ¤ #
" Pλk £ n ¤ #)
min
i=1
p1 i
γ1
i=1
,
p2 i
γ2
,··· ,
i=1
pk i
γk
where λi is a positive integer satisfying pi λi ≤ n < pi λi +1 for i = 1, 2, · · · , k.
Example. Let’s find the number of zeros of 100! on base 7441875. Since
7441875 = 35 · 54 · 72 , and all of 3, 5, and 7 are primes less than 100, we
calculate
(" P4 £ ¤ # " P2 £ ¤ # " P2 £ ¤ #)
min
i=1
100
3i
,
i=1
100
5i
,
i=1
100
7i
5
4
2
nh 48 i h 24 i h 16 io
= min
,
,
= min{9, 6, 8} = 6.
5
4
2
Therefore, there are 6 zeros at the end of 100! on base 7441875.
References
[1] Paul R. Halmos, Problems for Mathematicans Young and Old, Mathematical Association of America, 1991.
[2] Jean-Marie De Koninck and Armel Mercier, 1001 Problems in Classical
Number Theory, American Mathematical Society, 2007.
[3] Kenneth H. Rosen, Elementary Number Theory and its Applicaiton, 4th
ed., Addison-Wisley, 2000.
© Copyright 2026 Paperzz