A trailing zero is any 0 digit that comes after the last nonzero digit in a number string in
positional notation. For digits ''before'' the decimal point, the trailing zeros between the
decimal point and the last nonzero digit are necessary for conveying the magnitude of a number and cannot be omitted (ex. 100), while
leading zeros – zeros occurring before the decimal point and before the first nonzero digit – can be omitted without changing the meaning (ex. 001). Any zeros appearing to the right of the last non-zero digit ''after'' the decimal point do not affect its value (ex. 0.100). Thus, decimal notation often does not use trailing zeros that come after the decimal point. However, trailing zeros that come after the decimal point may be used to indicate the number of
significant figures
Significant figures, also referred to as significant digits, are specific digits within a number that is written in positional notation that carry both reliability and necessity in conveying a particular quantity. When presenting the outcom ...
, for example in a measurement, and in that context, "simplifying" a number by removing trailing zeros would be incorrect.
The number of trailing zeros in a non-zero base-''b''
integer
An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
''n'' equals the exponent of the highest power of ''b'' that divides ''n''. For example, 14000 has three trailing zeros and is therefore divisible by 1000 = 10
3, but not by 10
4. This property is useful when looking for small factors in
integer factorization
In mathematics, integer factorization is the decomposition of a positive integer into a product of integers. Every positive integer greater than 1 is either the product of two or more integer factors greater than 1, in which case it is a comp ...
. Some
computer architectures have a
count trailing zeros operation in their
instruction set
In computer science, an instruction set architecture (ISA) is an abstract model that generally defines how software controls the CPU in a computer or a family of computers. A device or program that executes instructions described by that ISA, s ...
for efficiently determining the number of trailing zero bits in a machine word.
In
pharmacy
Pharmacy is the science and practice of discovering, producing, preparing, dispensing, reviewing and monitoring medications, aiming to ensure the safe, effective, and affordable use of medication, medicines. It is a miscellaneous science as it ...
, trailing zeros are omitted from
dose values to prevent misreading.
Factorial
The number of trailing zeros in the
decimal representation
A decimal representation of a non-negative real number is its expression as a sequence of symbols consisting of decimal digits traditionally written with a single separator:
r = b_k b_\cdots b_0.a_1a_2\cdots
Here is the decimal separator, ...
of ''n''!, the
factorial
In mathematics, the factorial of a non-negative denoted is the Product (mathematics), product of all positive integers less than or equal The factorial also equals the product of n with the next smaller factorial:
\begin
n! &= n \times ...
of a
non-negative integer
An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
''n'', is simply the multiplicity of the
prime factor 5 in ''n''
!. This can be determined with this special case of
de Polignac's formula:
[Summarized fro]
Factorials and Trailing Zeroes
/ref>
:
where ''k'' must be chosen such that
:
more precisely
:
:
and denotes the floor function applied to ''a''. For ''n'' = 0, 1, 2, ... this is
:0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 6, ... .
For example, 53 > 32, and therefore 32! = 263130836933693530167218012160000000 ends in
:
zeros. If ''n'' < 5, the inequality is satisfied by ''k'' = 0; in that case the sum is empty, giving the answer 0.
The formula actually counts the number of factors 5 in ''n''!, but since there are at least as many factors 2, this is equivalent to the number of factors 10, each of which gives one more trailing zero.
Defining
:
the following recurrence relation holds:
:
This can be used to simplify the computation of the terms of the summation, which can be stopped as soon as ''q i'' reaches zero. The condition is equivalent to
See also
* Trailing digit
References
External links
''Why are trailing fractional zeros important?''
for some examples of when trailing zeros are significant
''Number of trailing zeros for any factorial''
Python program to calculate the number of trailing zeros for any factorial {{Webarchive, url=https://web.archive.org/web/20170222203959/http://blog.dreamshire.com/trailing_zeros_in_factorials/ , date=2017-02-22
Elementary arithmetic
0 (number)