Trailing Zeros in n Factorial
Count decimal trailing zeros of n! exactly by counting factors of five, accepting nonnegative decimal integers up to 200 characters.
Description
Decimal trailing zeros in a factorial come from paired factors of two and five.
Decimal trailing zeros in a factorial come from paired factors of two and five. Factors of five are the limiting supply, including extra factors from powers of five.1
The tool returns zeros. The indexing and output conventions below determine how to read these values.
When to use Trailing Zeros in n Factorial
Use this for the following task: Count decimal trailing zeros of n! exactly by counting factors of five, accepting nonnegative decimal integers up to 200 characters. Use the input and output conventions below to reproduce the intended mathematical quantity.
How to use Trailing Zeros in n Factorial and understand its results
- Choose the required indexes, integers or sequence entries. Preserve decimal-string encodings where the field table specifies strings.
- Enter n according to the field table, then run the tool.
- Read zeros. Preserve exact decimal strings and the stated indexing or coefficient order.
- Keep exact decimal strings for subsequent integer arithmetic; distinguish them from any explicitly approximate numeric result.
| Input field | Meaning | Value type and bounds | Requirement |
|---|---|---|---|
| n | Nonnegative factorial argument | string (integer/arbitrary); maximum text length 200; pattern ^(0|[1-9][0-9]*)$ | Required |
Parse n as BigInt and repeatedly divide by five, adding each positive quotient until it becomes zero. Return an exact decimal count.
zeros(n!)=Σ[j≥1]floor(n/5^j) The symbols and boundary conditions refer to the supplied fields and the implementation described above.
| Output field | Meaning | Value type |
|---|---|---|
| zeros | Number of trailing decimal zeros | string (integer/arbitrary) |
{
"input": {
"n": "100"
},
"output": {
"zeros": "24"
}
} Limitations and assumptions
The factorial itself is never constructed. The tool checks base ten only; n=0 returns zero trailing zeros because 0!=1.
Use the declared integer bounds and string formats. Large exact outputs remain decimal strings; numerical approximations use ordinary floating-point arithmetic. A rejected input is different from a valid zero count or false membership flag.
Alternative or Complementary methods
Choose Factorion Checker when you need its operation: Check whether a nonnegative decimal integer equals the sum of factorials of its digits, including 0!=1 and an input resource limit of 200 characters. Choose Euler’s Number from the Factorial Series for the complementary operation: Approximate e by summing the first requested terms of Σ1/k!, beginning with k=0, using compensated floating-point addition and a 10,000-term resource limit.
Background reference: OEIS A027868.
References
-
OEIS A027868 — OEIS Foundation
Similar or alternative tools
- Factorion Checker
Check whether a nonnegative decimal integer equals the sum of factorials of its digits, including 0!=1 and an input resource limit of 200 characters.
- Euler’s Number from the Factorial Series
Approximate e by summing the first requested terms of Σ1/k!, beginning with k=0, using compensated floating-point addition and a 10,000-term resource limit.