Trailing zeros
   HOME

TheInfoList



OR:

In mathematics, trailing zeros are a sequence of 0 in the decimal representation (or more generally, in any positional representation) of a number, after which no other digits follow. Trailing zeros to the right of a
decimal point A decimal separator is a symbol used to separate the integer part from the fractional part of a number written in decimal form (e.g., "." in 12.45). Different countries officially designate different symbols for use as the separator. The choi ...
, as in 12.3400, do not affect the value of a number and may be omitted if all that is of interest is its numerical value. This is true even if the zeros recur infinitely. For example, in pharmacy, trailing zeros are omitted from dose values to prevent misreading. However, trailing zeros may be useful for indicating the number of
significant figures Significant figures (also known as the significant digits, ''precision'' or ''resolution'') of a number in positional notation are digits in the number that are reliable and necessary to indicate the quantity of something. If a number expres ...
, for example in a measurement. In such a 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 (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the languag ...
''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 = 103, but not by 104. This property is useful when looking for small factors in integer factorization. Some
computer architectures In computer engineering, computer architecture is a description of the structure of a computer system made from component parts. It can sometimes be a high-level description that ignores details of the implementation. At a more detailed level, the ...
have a
count trailing zeros In computer software and hardware, find first set (ffs) or find first one is a bit operation that, given an unsigned machine word, designates the index or position of the least significant bit set to one in the word counting from the least signifi ...
operation in their instruction set for efficiently determining the number of trailing zero bits in a machine word.


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_\ldots b_0.a_1a_2\ldots Here is the decimal separator, i ...
of ''n''!, the factorial of a
non-negative In mathematics, the sign of a real number is its property of being either positive, negative, or zero. Depending on local conventions, zero may be considered as being neither positive nor negative (having no sign or a unique third sign), or it ...
integer An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the languag ...
''n'', is simply the multiplicity of the
prime A prime number (or a prime) is a natural number greater than 1 that is not a product of two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways ...
factor 5 in ''n''!. This can be determined with this special case of
de Polignac's formula In mathematics, Legendre's formula gives an expression for the exponent of the largest power of a prime ''p'' that divides the factorial ''n''!. It is named after Adrien-Marie Legendre. It is also sometimes known as de Polignac's formula, aft ...
:Summarized fro
Factorials and Trailing Zeroes
/ref> :f(n) = \sum_^k \left \lfloor \frac \right \rfloor = \left \lfloor \frac \right \rfloor + \left \lfloor \frac \right \rfloor + \left \lfloor \frac \right \rfloor + \cdots + \left \lfloor \frac \right \rfloor, \, where ''k'' must be chosen such that :5^ > n,\, more precisely :5^ \le n < 5^, :k = \left \lfloor \log_ n \right \rfloor, and \lfloor a \rfloor denotes the
floor function In mathematics and computer science, the floor function is the function that takes as input a real number , and gives as output the greatest integer less than or equal to , denoted or . Similarly, the ceiling function maps to the least int ...
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 :\left \lfloor \frac \right \rfloor + \left \lfloor \frac \right \rfloor = 6 + 1 = 7\, zeros. If ''n'' < 5, the inequality is satisfied by ''k'' = 0; in that case the sum is
empty Empty may refer to: ‍ Music Albums * ''Empty'' (God Lives Underwater album) or the title song, 1995 * ''Empty'' (Nils Frahm album), 2020 * ''Empty'' (Tait album) or the title song, 2001 Songs * "Empty" (The Click Five song), 2007 * ...
, 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 :q_i = \left \lfloor \frac \right \rfloor,\, the following
recurrence relation In mathematics, a recurrence relation is an equation according to which the nth term of a sequence of numbers is equal to some combination of the previous terms. Often, only k previous terms of the sequence appear in the equation, for a parameter ...
holds: :\beginq_0\,\,\,\,\, & = \,\,\,n,\quad \\ q_ & = \left \lfloor \frac \right \rfloor.\,\end 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

* Leading zero *
Trailing digit Significant figures (also known as the significant digits, ''precision'' or ''resolution'') of a number in positional notation are digits in the number that are reliable and necessary to indicate the quantity of something. If a number expres ...


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''
ython 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)