HOME
The Info List - Trailing Zeros


--- Advertisement ---



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, 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, 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 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 have a count trailing zeros operation in their instruction set for efficiently determining the number of trailing zero bits in a machine word.

Contents

1 Factorial 2 See also 3 References 4 External links

Factorial[edit] The number of trailing zeros in the decimal representation of n!, the factorial of a non-negative integer 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:[1]

f ( n ) =

i = 1

k

n

5

i

=

n 5

+

n

5

2

+

n

5

3

+ ⋯ +

n

5

k

,

displaystyle f(n)=sum _ i=1 ^ k leftlfloor frac n 5^ i rightrfloor =leftlfloor frac n 5 rightrfloor +leftlfloor frac n 5^ 2 rightrfloor +leftlfloor frac n 5^ 3 rightrfloor +cdots +leftlfloor frac n 5^ k rightrfloor ,,

where k must be chosen such that

5

k + 1

> n ,

displaystyle 5^ k+1 >n,,

more precisely

5

k

≤ n <

5

k + 1

,

displaystyle 5^ k leq n<5^ k+1 ,

k =

log

5

⁡ n

,

displaystyle k=leftlfloor log _ 5 nrightrfloor ,

and

⌊ a ⌋

displaystyle lfloor arfloor

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, ... (sequence A027868 in the OEIS).

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

32 5

+

32

5

2

= 6 + 1 = 7

displaystyle leftlfloor frac 32 5 rightrfloor +leftlfloor frac 32 5^ 2 rightrfloor =6+1=7,

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

q

i

=

n

5

i

,

displaystyle q_ i =leftlfloor frac n 5^ i rightrfloor ,,

the following recurrence relation holds:

q

0

=

n ,

q

i + 1

=

q

i

5

.

displaystyle begin aligned q_ 0 ,,,,,&=,,,n,quad \q_ i+1 &=leftlfloor frac q_ i 5 rightrfloor .,end aligned

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 5k+1 > n is equivalent to q k+1 = 0. See also[edit]

Leading zero

References[edit]

^ Summarized from Factorials and Trailing Zeroes

External links[edit]

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

.