Factorial Zeros

More Details

The factorial of a positive integer n, written as n!, is the product of all the integers from 1 to n. For example, 4! = 1×2×3×4=24.

What Your Function Should Do

Write a function FactorialZeros that takes an integer n as an input and outputs the number of zeros at the end of n!.

100!

FactorialZeros[100]

Because factorials grow very fast, it is not a good strategy to calculate n! and count the zeros.

More Examples

FactorialZeros[100]

FactorialZeros[5]

FactorialZeros[124]

FactorialZeros[38]

Things You May Find Useful

For n>5, there is always some number of zeros at the end of n! because of factors divisible by 2 and 5.

For example, 20! has four zeros at the end of its decimal expansion:

20!

The function FactorialZeros will count the zeros at the end of 100!:

100!

Learn more about the factorial:

(HyperlinkTemplate["Factorial »", http://mathworld.wolfram.com/Factorial.html, http://mathworld.wolfram.com/Factorial.html, Hyperlink, Text, ])

FactorialZeros[n_Integer]:=