Factorial
The factorial n! = n×(n-1)×...×1 is the basis of permutations and combinations; it grows extremely fast, with 20! already exceeding the 64-bit integer range.
Purpose
To count permutations of n elements, a foundation of combinatorics.
Mechanism
n! = n×(n-1)!, with 0!=1. Stirling's approximation: n! ≈ √(2πn)(n/e)^n. Large n requires BigInteger. The Γ function extends the factorial to non-integers. Log-factorials use lgamma to avoid overflow.
Use cases
- Permutation and combination counting
- Probability and statistics (Poisson distribution)
- Taylor series coefficients
- Gamma function
Examples
- Input
5=5×4×3×2×1=120Output120Number of permutations of 5 elements
Common errors
- Factorial overflow for large n
- Use BigInteger or log-factorials
Related terms
Permutation
A permutation counts the ordered ways to choose k elements from n, P(n,k)=n!/(n-k)!; the full permutation count is n!. GLOSSARY
Combination
A combination counts the ways to choose k elements from n without regard to order, C(n,k)=n!/(k!(n-k)!), i.e., the binomial coefficient. GLOSSARY
Fibonacci Sequence
The Fibonacci sequence has each term equal to the sum of the two before it (0,1,1,2,3,5,8...); it relates to the golden ratio and appears widely in nature and algorithms. GLOSSARY
BigInteger
BigInteger is an arbitrary-precision integer type, not limited by a fixed word size, used for computations beyond the native integer range (such as cryptography and combinatorics). GLOSSARY
Related tools
Precision Calculator
High-precision arithmetic calculator. No floating-point errors. Free, private, 100% client-side. TOOL
Factorial Calculator
Factorial Calculator — pure client-side tool. Privacy-first, no server round-trip. TOOL
Permutation Calculator
Permutation Calculator — pure client-side tool. Privacy-first, no server round-trip. TOOL
Combination Calculator
Combination Calculator — pure client-side tool. Privacy-first, no server round-trip. TOOL
Binomial Coefficient
Binomial Coefficient — pure client-side tool. Privacy-first, no server round-trip. TOOL