Trailing Number of Zeros
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
The number has 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.
Trailing zeros are often discussed in terms of the base-ten representation of factorials.
Count the number of trailing zeros in
has trailing zeros.
It's not very efficient to compute the entire base-ten representation of a number like 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 (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.
Theory of Trailing Zeros
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
- 18720 has 1 trailing zero. The highest power of ten it is divisible by is
- 6781900 has 2 trailing zeros. The highest power of ten it is divisible by is
- 95000 has 3 trailing zeros. The highest power of ten it is divisible by is
- 22810000 has 4 trailing zeros. The highest power of ten it is divisible by is
It's pretty clear that if an integer is divisible by then it has trailing zeros. Now consider the prime factorizations of integers and how this affects trailing zeros.
How many trailing zeros do these numbers have?
For the four numbers given, the answers are as follows:
- and can be combined to make There are 4 trailing zeros.
- and can be combined to make There are 3 trailing zeros.
- and can be combined to make There is 1 trailing zero.
- and can be combined to make There are 2 trailing zeros.
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 , where is an integer such that and then the number of trailing zeros that integer has is
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.
Factorials in Base Ten
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 and find the number of trailing zeros of
We have
which can be rewritten as
The minimum power between and is 2. Therefore, has trailing zeros.
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 can be expressed as where is an integer such that then the number of trailing zeros in is
Prove that the number of trailing zeros of are all the same.
Let denote the number of trailing zeros of .
Factorizing gives .
Similarly, factorizing gives
Because the highest power of 5 that divides is 1, they all have the same number of trailing zeros.
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
There are multiples of 5 that are less than or equal to 30. Therefore, there are numbers in the factorial product that contain a power of 5:
Note that one of these numbers, contributes a higher power of 5 to the product. That is, while the other 5 multiples contain a factor. Therefore, the number of trailing zeros of is
Note that each multiple of 5 in the factorial product will contribute to the number of trailing zeros. On top of this, each multiple of 25 will contribute an additional to the number of trailing zeros. Then, each multiple of 125 will contribute another to the number of trailing zeros, and so on.
Find the number of trailing zeros in .
The number of multiples of 5 that are less than or equal to 500 is
Then, the number of multiples of 25 is
Then, the number of multiples of 125 is
The next power of 5 is 625, which is greater than 500.Therefore, the number of trailing zeros of is
As you probably have realized, we can determine the number of trailing zeros of for any positive integer . Do give the following example a try and see if you're able to spot a nice way to express it.
The above some of the digits of the . 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 .
- The number of multiples of 25 that are less than or equal to 1000 is .
- The number of multiples of 125 that are less than or equal to 1000 is .
- The only multiple of 625 that is less than or equal to 1000 is 625 itself.
Thus, has a total of trailing zeros.
There's a fancy way to express this strategy using the floor function and logarithms:
Let give the number of trailing zeros in the base ten representation of . Then,
where
Actually, could be , but when , 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 .
We plug in 777 to the formula and get
Note that the sequence stopped after 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.
Find the number of trailing zeros of the number .
2015! is multiplied by itself 2015 times as follows:
Count how many trailing zeros there are!
Determine the number of trailing zeros of .
We plug in 10005 to the formula and get
Note that the sequence would stop after because everything after that would be 0. So the answer .
For how many positive integral values of does end with precisely 23 trailing zeros?
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 and prime number let be the sum of digits of in base and let be the highest power of in Then,
Find the number of trailing zeros in
For the formula above, Given that this factorial is in base ten, the goal is to find the highest power of in Therefore,
First, it is necessary to compute the number in base 5:
Then
The sum of the digits of 452 in base 5 is
Using the formula above, the highest power of 5 in is
Therefore, there are trailing zeros in
Trailing Zeros in other Bases
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,
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 Therefore, there are 0 trailing zeros in base 6.
- The highest power of 6 that 756 is divisible by is Therefore, there are 2 trailing zeros in base 6.
- The highest power of 6 that 864 is divisible by is Therefore, there are 3 trailing zeros in base 6.
This principle can be applied to any number base.
If an integer can be expressed as where and are integers such that is positive, is non-negative, and then the number of trailing zeros of in base is
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 in base 12.
We have
which can be rewritten as
Note that Then,
Therefore, the number of trailing zeros of in base 12 is
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 give the highest power of in . Then,
where
Find the number of trailing zeros of in base 45.
Note that
Find the power of in
The power of 3 in is 48, so the power of 9 in is 24. Then, where is an integer such that
Find the power of in
Then, where is an integer such that and
Therefore, has trailing zeros in base 45.
Find the number of trailing zeros in the base-17 representation of
Clarification: 2017, as it is written here, is in base 10.
Find the smallest integer such that when is written in base 12, it has 121 trailing zeros. Enter your answer in base 6.