## Task 4 - 130914

Under $n$! (read as $n$-factorial) one understands the product of all natural numbers from 1 to $n$; that is,

$$
n!=1 \cdot 2 \cdot 3 \cdot \ldots \cdot(n-3) \cdot(n-2) \cdot(n-1) \cdot n
$$

Determine for $n=1000$ the number of zeros at the end of the number $n$! (trailing zeros).
Let $x$ be the number of trailing zeros of the number 1000!. Then 1000! $=z \cdot 10^{x}$, where $z$ is a natural number that does not end in 0. Since $10^{x}=2^{x} \cdot 5^{x}$, the number of trailing zeros is equal to the smaller of the number of factors 2 and 5 contained in the number 1000!. Because every second natural number is even, but only every fifth natural number is divisible by 5, the number 1000! contains more factors 2 than factors 5. Therefore, the number of trailing zeros is equal to the number of factors 5 contained in 1000!.

Now, among the natural numbers from 1 to 1000, there is exactly one number divisible by $625=5^{4}$, among the remaining 999 numbers, there are exactly 8-1 numbers divisible by $125=5^{3}$, namely the numbers $n \cdot 125$ with $1 \leq n \leq 8$ and $n \neq 5$; among the remaining 992 numbers, there are exactly $40-8$ numbers divisible by $25=5^{2}$, namely the numbers $n \cdot 25$ with $1 \leq n \leq 40$ and $n \neq 5,10,15, \ldots, 40$, i.e., $n \neq k \cdot 5(k=1, \ldots, 8)$; finally, among the remaining 960 numbers, there are exactly 200-40 numbers divisible by 5, namely the numbers $n \cdot 5$ with $1 \leq n \leq 200$ and $n \neq k \cdot 5(k=1, \ldots, 40)$. Therefore, the number 1000! contains

$$
4+3(8-1)+2(40-8)+(200-40)=200+40+8+1=249
$$

exactly 249 factors of 5 and thus ends with exactly 249 zeros.