Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Trailing zero

From Wikipedia, the free encyclopedia
Zero after the final non-zero digit of a number

Atrailing zero is any 0 digit that comes after the last nonzero digit in a number string inpositional notation. For digitsbefore the decimal point, the trailing zeros between thedecimal point and the last nonzero digit are necessary for conveying the magnitude of a number and cannot be omitted (ex. 100), whileleading 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 digitafter 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 ofsignificant figures, 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-bintegern equals the exponent of the highest power ofb that dividesn. 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 ininteger factorization. Somecomputer architectures have acount trailing zeros operation in theirinstruction set for efficiently determining the number of trailing zero bits in a machine word.

Inpharmacy, trailing zeros are omitted fromdose values to prevent misreading.

Factorial

[edit]

The number of trailing zeros in thedecimal representation ofn!, thefactorial of anon-negativeintegern, is simply the multiplicity of theprime factor 5 inn!. This can be determined with this special case ofde Polignac's formula:[1]

f(n)=i=1kn5i=n5+n52+n53++n5k,{\displaystyle 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 +\cdots +\left\lfloor {\frac {n}{5^{k}}}\right\rfloor ,\,}

wherek must be chosen such that

5k+1>n,{\displaystyle 5^{k+1}>n,\,}

more precisely

5kn<5k+1,{\displaystyle 5^{k}\leq n<5^{k+1},}
k=log5n,{\displaystyle k=\left\lfloor \log _{5}n\right\rfloor ,}

anda{\displaystyle \lfloor a\rfloor } denotes thefloor function applied toa. Forn = 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, ... (sequenceA027868 in theOEIS).

For example, 53 > 32, and therefore 32! = 263130836933693530167218012160000000 ends in

325+3252=6+1=7{\displaystyle \left\lfloor {\frac {32}{5}}\right\rfloor +\left\lfloor {\frac {32}{5^{2}}}\right\rfloor =6+1=7\,}

zeros. Ifn < 5, the inequality is satisfied byk = 0; in that case the sum isempty, giving the answer 0.

The formula actually counts the number of factors 5 inn!, 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

qi=n5i,{\displaystyle q_{i}=\left\lfloor {\frac {n}{5^{i}}}\right\rfloor ,\,}

the followingrecurrence relation holds:

q0=n,qi+1=qi5.{\displaystyle {\begin{aligned}q_{0}\,\,\,\,\,&=\,\,\,n,\quad \\q_{i+1}&=\left\lfloor {\frac {q_{i}}{5}}\right\rfloor .\,\end{aligned}}}

This can be used to simplify the computation of the terms of the summation, which can be stopped as soon asq i reaches zero. The condition5k+1 >n is equivalent toq k+1 = 0.

See also

[edit]

References

[edit]
  1. ^Summarized fromFactorials and Trailing Zeroes

External links

[edit]
Retrieved from "https://en.wikipedia.org/w/index.php?title=Trailing_zero&oldid=1280117427"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp