A **trailing zero** is a zero digit in the representation of a number which has no non-zero digits that are less significant than the zero digit. Put more simply, it is a zero digit with no non-zero digits to the right of it.

How many trailing zeros are in the number \(910034050000?\)

\[91003405{\color{green}0000}\]

The number has \(\boxed{4}\) trailing zeros. Note that there are 3 other zeros in the representation of the number, but they do not count as trailing zeros because there are other non-zero digits that are less significant. \(_\square\)

Trailing zeros are often discussed in terms of the base-ten representation of factorials.

Count the number of trailing zeros in \(15!.\)

\[15!=15\times14\times13\times\cdots\times1 = 1307674368\color{green}{000}\]

\(15!\) has \(\boxed{3}\) trailing zeros. \(_\square\)

It's not very efficient to compute the entire base-ten representation of a number like \(15!\) in order to count the trailing zeros. It would be even more cumbersome to apply the same method to count the trailing zeros in a number like \(100!\) (a number which contains 158 digits). Therefore, it's desirable to come up with more efficient methods for counting the trailing zeros of factorials. This page will explore these methods.

Before getting into how to compute trailing zeros of a factorial, first consider where trailing zeros come from.

How many trailing zeros do these numbers have? What's the largest power of ten these numbers are divisible by?

- 123
- 18720
- 6781900
- 95000
- 22810000
For the five numbers given, the answers are as follows:

- 123 has 0 trailing zeros and is not divisible by 10. The highest power of ten it is divisible by is \(10^0=1.\)
- 18720 has 1 trailing zero. The highest power of ten it is divisible by is \(10^1=10.\)
- 6781900 has 2 trailing zeros. The highest power of ten it is divisible by is \(10^2=100.\)
- 95000 has 3 trailing zeros. The highest power of ten it is divisible by is \(10^3=1000.\)
- 22810000 has 4 trailing zeros. The highest power of ten it is divisible by is \(10^4=10000.\) \(_\square\)

It's pretty clear that if an integer is divisible by \(10^k,\) then it has \(k\) trailing zeros. Now consider the prime factorizations of integers and how this affects trailing zeros.

How many trailing zeros do these numbers have?

- \(2^5 \times 5^4\)
- \(2^3 \times 3^1 \times 5^4 \times 7^2\)
- \(2^1 \times 5^5 \times 11^1\)
- \(2^6 \times 3^2 \times 5^2 \times 13^1 \times 17^2\)
For the four numbers given, the answers are as follows:

- \(2^5 \times 5^4:\) \(2^4\) and \(5^4\) can be combined to make \(10^4.\) There are 4 trailing zeros.
- \(2^3 \times 3^1 \times 5^4 \times 7^2:\) \(2^3\) and \(5^3\) can be combined to make \(10^3.\) There are 3 trailing zeros.
- \(2^1 \times 5^5 \times 11^1:\) \(2^1\) and \(5^1\) can be combined to make \(10^1.\) There is 1 trailing zero.
- \(2^6 \times 3^2 \times 5^2 \times 13^1 \times 17^2:\) \(2^2\) and \(5^2\) can be combined to make \(10^2.\) There are 2 trailing zeros. \(_\square\)

In each case, the number of trailing zeros comes from the power of 2 or the power of 5, whichever is smaller. The remaining factors do not matter for trailing zeros. This leads to the following theorem:

If an integer can be expressed as \(2^a \times 5^b \times k\), where \(k\) is an integer such that \(2 \nmid k\) and \(5 \nmid k,\) then the number of trailing zeros that integer has is \(\min(a,b).\)

This insight becomes important for efficiently finding the number of trailing zeros in factorials. It is sufficient to find the lesser of the powers of 2 or 5, so it is not necessary to count the greater of those powers.

In light of the above theorem, the strategy for finding the trailing zeros of a factorial will revolve around the prime factorization of the factorial.

Give the prime factorization of \(10!,\) and find the number of trailing zeros of \(10!.\)

We have

\[\begin{array}{ccccccccccccccccccccc}10! & = & 10 & \times & 9 & \times & 8 & \times & 7 & \times & 6 & \times & 5 & \times & 4 & \times & 3 & \times & 2 & \times & 1 \\& = & 2^1 \times 5^1 & \times & 3^2 & \times & 2^3 & \times & 7^1 & \times & 2^1 \times 3^1 & \times & 5^1 & \times & 2^2 & \times & 3^1 & \times & 2^1,\end{array}\]

which can be rewritten as

\[10! = 2^8 \times 3^4 \times 5^2 \times 7^1.\]

The minimum power between \(2^8\) and \(5^2\) is 2. Therefore, \(10!\) has \(\boxed{2}\) trailing zeros. \(_\square\)

Consider how in the above example, the power of 2 was much higher than the power of 5. This is the case for all factorials because multiples of 2 show up much more often in the factorial product than multiples of 5. Therefore, it is sufficient to find the power of 5 when computing the trailing zeros of a factorial.

If \(n!\) can be expressed as \(5^a \times k,\) where \(k\) is an integer such that \(5 \nmid k,\) then the number of trailing zeros in \(n!\) is \(a.\)

Prove that the number of trailing zeros of \(6!,7!,8!,9!\) are all the same.

Let \(n\) denote the number of trailing zeros of \(6!\).

Factorizing \(6!\) gives \(1\times2\times3\times4\times5\times6=2^4\times3^2\times5\).

Similarly, factorizing \(7!,8!,9!\) gives\[\begin{eqnarray}7!&=& 7\times6! = 2^4\times3^2\times5\times 7\\8!&= &8\times 7! = 2^4\times3^2\times5 \times 7 \times 2^3 \\9!&= &9\times 8! = 2^4\times3^2\times5 \times 7 \times 2^3 \times 3^2.\end{eqnarray} \]

Because the highest power of 5 that divides \(6!,7!,8!,9!\) is 1, they all have the same number of trailing zeros. \(_\square \)

The strategy now is to count the number of multiples of 5 there are in the factorial product. However, one must also consider that a number in the factorial product can contribute a power of 5 greater than 1.

Find the number of trailing zeros in \(30!.\)

There are \(6\) multiples of 5 that are less than or equal to 30. Therefore, there are \(6\) numbers in the factorial product that contain a power of 5:

\[30!=30 \times 25 \times 20 \times 15 \times 10 \times 5 \times k.\]

Note that one of these numbers, \(25,\) contributes a higher power of 5 to the product. That is, \(25=5^2,\) while the other 5 multiples contain a \(5^1\) factor. Therefore, the number of trailing zeros of \(30!\) is \(\boxed{7}.\) \(_\square\)

Note that each multiple of 5 in the factorial product will contribute \(1\) to the number of trailing zeros. On top of this, each multiple of 25 will contribute an additional \(1\) to the number of trailing zeros. Then, each multiple of 125 will contribute another \(1\) to the number of trailing zeros, and so on.

Find the number of trailing zeros in \(500!\).

The number of multiples of 5 that are less than or equal to 500 is \(500 \div 5 =100.\)

Then, the number of multiples of 25 is \(500 \div 25 = 20.\)

Then, the number of multiples of 125 is \(500 \div 125 = 4.\)

The next power of 5 is 625, which is greater than 500.Therefore, the number of trailing zeros of \(500!\) is \(100+20+4=\boxed{124}.\) \(_\square\)

As you probably have realized, we can determine the number of trailing zeros of \(N!\) for any positive integer \(N\). Do give the following example a try and see if you're able to spot a nice way to express it.

\[ 1000! = 4023872600770 \ldots 472 \underbrace{0000000 \ldots 0}_{\text{Plenty of 0's}} \]

The above some of the digits of the \(1000!\). How many (trailing) zeros are there at the end of this number?

The way to solve this is exactly the same as the previous example:

- The number of multiples of 5 that are less than or equal to 1000 is \(1000\div5 = 200 \).
- The number of multiples of 25 that are less than or equal to 1000 is \(1000\div25 = 40 \).
- The number of multiples of 125 that are less than or equal to 1000 is \(1000\div125 = 8 \).
- The only multiple of 625 that is less than or equal to 1000 is 625 itself.
Thus, \(1000!\) has a total of \(200 + 40 + 8 + 1 = \boxed{249} \) trailing zeros.

There's a fancy way to express this strategy using the floor function and logarithms:

Let \(f(n)\) give the number of trailing zeros in the base ten representation of \(n!\). Then,

\[\begin{align}f(n) &= \sum_{i=1}^k \left\lfloor{\frac{n}{5^i}}\right\rfloor \\ \\&= \left\lfloor{\frac{n}{5}}\right\rfloor+\left\lfloor{\frac{n}{5^2}}\right\rfloor+\left\lfloor{\frac{n}{5^3}}\right\rfloor+\dots+\left\lfloor{\frac{n}{5^k}}\right\rfloor,\end{align}\]

where \(k=\left\lfloor \log_5{n} \right\rfloor.\)

Actually, \(k\) could be \(\infty\), but when \(5^k > n\), \[0~<~\frac{n}{5^k}~<~1~\iff~\left\lfloor{\frac{n}{5^k}}\right\rfloor=0,\] so it does not matter on the main sum.

The first term counts the number of times a multiple of 5 appears in the factorial product, the second counts for multiples of 25, and so on.

Determine the number of trailing zeros of \(777!\).

We plug in 777 to the formula and get

\[\begin{eqnarray} \left\lfloor{\frac{777}{5}}\right\rfloor+\left\lfloor{\frac{777}{25}}\right\rfloor+\left\lfloor{\frac{777}{125}}\right\rfloor+\left\lfloor{\frac{777}{625}}\right\rfloor &= & 155+31+6+1 \\ &=&193. \ _\square \end{eqnarray} \]

Note that the sequence stopped after \(\left\lfloor{\frac{777}{625}}\right\rfloor\) because everything after that would be 0. You don't have to memorize fancy formulas to do this kind of problem consistently, but just know how and why it works.

10 14 15 16

Find the number of trailing zeros of the number \(60!\).

2015! is multiplied by itself 2015 times as follows:

\[\underbrace { 2015!\times 2015!\times\cdots\times 2015! }_{ 2015 }.\]

Count how many trailing zeros there are!

Determine the number of trailing zeros of \(10005!\).

We plug in 10005 to the formula and get

\[\begin{eqnarray} \left\lfloor { \frac { 10005 }{ 5 } } \right\rfloor +\left\lfloor { \frac { 10005 }{ 25 } } \right\rfloor +\left\lfloor { \frac { 10005 }{ 125 } } \right\rfloor +\left\lfloor { \frac { 10005 }{ 625 } } \right\rfloor +\left\lfloor { \frac { 10005 }{ 3125 } } \right\rfloor & = & 2001+400+80+16+3 \\ & = & 2500. \end{eqnarray} \]

Note that the sequence would stop after \(\left\lfloor{\frac{10005}{3125}}\right\rfloor\) because everything after that would be 0. So the answer \(2500\). \(_\square\)

\[0\] \[3\] \[4\] \[5\]

For how many positive integral values of \(n\) does \(n!\) end with precisely 23 trailing zeros?

\[ \dfrac{2002!}{(1001!)^2}\]

How many trailing zeroes does the number above have?

An alternative way to compute the trailing zeros of a factorial is given by analyzing the number in a different prime base.

Given an integer \(n\) and prime number \(p,\) let \({ S }_{ p }(n)\) be the sum of digits of \(n\) in base \(p,\) and let \(v_p(n)\) be the highest power of \(p\) in \(n!.\) Then,

\[ { v }_{ p }(n) = \frac { n - { S }_{ p }(n) }{ p - 1 }. \]

Find the number of trailing zeros in \(452!.\)

For the formula above, \(n=452.\) Given that this factorial is in base ten, the goal is to find the highest power of \(5\) in \(452!.\) Therefore, \(p=5.\)

First, it is necessary to compute the number in base 5:

\[\begin{align}\left\lfloor \frac{452}{125} \right\rfloor &= 3 \\452 - 3 \cdot 125 &= 77 \\ \\\left\lfloor \frac{77}{25} \right\rfloor &= 3 \\77 - 3 \cdot 25 &= 2 \\ \\\left\lfloor \frac{2}{5} \right\rfloor &= 0.\end{align}\]

Then \(452_{10}=3302_{5}.\)

The sum of the digits of 452 in base 5 is

\[S_5(452)=3+3+0+2=8.\]

Using the formula above, the highest power of 5 in \(452!\) is

\[\begin{align}v_5(452) &= \frac{452-8}{5-1} \\\\&= 111.\end{align}\]

Therefore, there are \(\boxed{111}\) trailing zeros in \(452!.\) \(_\square\)

The process for finding the number of trailing zeros in other prime bases is similar to the process of that in base ten. First, consider what causes a trailing zero in a different number base.

How many trailing zeros do these base-10 numbers have in base 6?

- 200
- 756
- 864
Converting each number to base 6,

\[\begin{align}200_{10} &= 532_{6}&: &\quad 0 \text{ trailing zeros} \\756_{10} &= 3300_{6}&: &\quad 2 \text{ trailing zeros} \\864_{10} &= 4000_{6}&: &\quad 3 \text{ trailing zeros}.\end{align}\]

It's clear that trailing zeros in base 10 do not translate to trailing zeros in base 6. As you convert to base 6, you may have noticed that the number of trailing zeros depends on the highest power of 6 that the number is divisible by:

- The highest power of 6 that 200 is divisible by is \(6^0.\) Therefore, there are 0 trailing zeros in base 6.
- The highest power of 6 that 756 is divisible by is \(6^2.\) Therefore, there are 2 trailing zeros in base 6.
- The highest power of 6 that 864 is divisible by is \(6^3.\) Therefore, there are 3 trailing zeros in base 6. \(_\square\)

This principle can be applied to any number base.

If an integer \(n\) can be expressed as \(b^a \times k,\) where \(a,\ b,\) and \(k\) are integers such that \(b\) is positive, \(a\) is non-negative, and \(b \nmid k,\) then the number of trailing zeros of \(n\) in base \(b\) is \(a.\)

This method makes it unnecessary to fully convert the number into the new base in order to count the trailing zeros. This is especially important for computing the trailing zeros of a factorial.

Find the number of trailing zeros of \(10!\) in base 12.

We have

\[\begin{array}{ccccccccccccccccccccc}10! & = & 10 & \times & 9 & \times & 8 & \times & 7 & \times & 6 & \times & 5 & \times & 4 & \times & 3 & \times & 2 & \times & 1 \\& = & 2^1 \times 5^1 & \times & 3^2 & \times & 2^3 & \times & 7^1 & \times & 2^1 \times 3^1 & \times & 5^1 & \times & 2^2 & \times & 3^1 & \times & 2^1,\end{array}\]

which can be rewritten as

\[10! = 2^8 \times 3^4 \times 5^2 \times 7^1.\]

Note that \(12=2^2\times 3^1.\) Then,

\[10! = 12^4 \times 5^2 \times 7^1.\]

Therefore, the number of trailing zeros of \(10!\) in base 12 is \(\boxed{4}.\) \(_\square\)

Note that there is a "bottleneck" of powers of 5 in base 10, but there isn't necessarily a consistent "bottleneck" in other bases. One must consider each prime power in the base when computing the trailing zeros. The method to compute the prime power of a factorial is very similar to the method for base 10:

Let \(v_p(n)\) give the highest power of \(p\) in \(n!\). Then,

\[\begin{align}v_p(n) &= \sum_{i=1}^k \left\lfloor{\frac{n}{p^i}}\right\rfloor \\ \\&= \left\lfloor{\frac{n}{p}}\right\rfloor+\left\lfloor{\frac{n}{p^2}}\right\rfloor+\left\lfloor{\frac{n}{p^3}}\right\rfloor+\dots+\left\lfloor{\frac{n}{p^k}}\right\rfloor,\end{align}\]

where \(k=\left\lfloor \log_p{n} \right\rfloor.\)

Find the number of trailing zeros of \(100!\) in base 45.

Note that \(45=3^2 \times 5.\)

Find the power of \(3\) in \(100!:\)

\[\begin{align}v_3(100) &= \left\lfloor \frac{100}{3} \right\rfloor + \left\lfloor \frac{100}{9} \right\rfloor + \left\lfloor \frac{100}{27} \right\rfloor + \left\lfloor \frac{100}{81} \right\rfloor \\&= 33+11+3+1 \\&= 48.\end{align}\]

The power of 3 in \(100!\) is 48, so the power of 9 in \(100!\) is 24. Then, \(100!=\big(3^2\big)^{24} \times k,\) where \(k\) is an integer such that \(3^2 \nmid k.\)

Find the power of \(5\) in \(100!:\)

\[\begin{align}v_5(100) &= \left\lfloor \frac{100}{5} \right\rfloor + \left\lfloor \frac{100}{25} \right\rfloor \\&= 20+4 \\&= 24.\end{align}\]

Then, \(100!=\big(3^2\big)^{24} \times 5^{24} \times l,\) where \(l\) is an integer such that \(3^2 \nmid l\) and \(5 \nmid l.\)

Therefore, \(100!\) has \(\boxed{24}\) trailing zeros in base 45. \(_\square\)

Find the number of trailing zeros in the base-17 representation of \(2017!.\)

**Clarification**: 2017, as it is written here, is in base 10.

Find the smallest integer \(N\) such that when \(N!\) is written in **base 12**, it has 121 trailing zeros. Enter your **answer in base 6**.