In
mathematics
Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, trailing zeros are a sequence of
0 in the
decimal
The decimal numeral system (also called the base-ten positional numeral system and denary or decanary) is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers of the Hindu–Arabic numeral ...
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, 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
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. 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 = 10
3, but not by 10
4. This property is useful when looking for small factors in
integer factorization
In number theory, integer factorization is the decomposition of a composite number into a product of smaller integers. If these factors are further restricted to prime numbers, the process is called prime factorization.
When the numbers are s ...
. 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 operation in their
instruction set
In computer science, an instruction set architecture (ISA), also called computer architecture, is an abstract model of a computer. A device that executes instructions described by that ISA, such as a central processing unit (CPU), is called an ...
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
In mathematics, the factorial of a non-negative denoted is the 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 (n-1) \times (n-2) \ ...
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:
[Summarized fro]
Factorials and Trailing Zeroes
/ref>
:
where ''k'' must be chosen such that
:
more precisely
:
:
and 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
:
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
:
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:
:
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
A leading zero is any 0 digit that comes before the first nonzero digit in a number string in positional notation.. For example, James Bond's famous identifier, 007, has two leading zeros. Any zeroes appearing to the left of the first non-zero d ...
* 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''
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)