The factorial of a whole number , written , is the product of all positive integers up to : . It counts the number of ways to arrange distinct objects in a row, which is why it sits at the heart of permutations, combinations, probability and series such as .
Factorials grow astonishingly fast. , already has 19 digits and has 158. Ordinary calculators give up at , the largest factorial a double-precision number can hold. This calculator uses exact integer arithmetic instead, so it returns every digit of for any up to 1000 (that is 2,568 digits), together with the digit count, the number of trailing zeros and the value in scientific notation.
Two related tools are built in: the double factorial , which multiplies every other number, and the gamma function , which extends the factorial to fractions and negative non-integers, so you can evaluate expressions like "".
How to use this calculator
- Pick n! for an ordinary factorial, n!! for a double factorial or Γ(x) for the gamma function.
- Enter (a whole number) or (any real number except 0 and negative integers in the gamma mode).
- Read the result: in full when it has up to 30 digits, otherwise in scientific notation, with all the digits listed in the table below it.
- Check the extra figures (number of digits, trailing zeros, ) and open the steps for the product, Legendre’s formula and Stirling’s approximation.
The formula
Factorial. For a non-negative integer ,
Double factorial. , stopping at 1 for odd and at 2 for even , with .
Gamma function. Euler’s integral satisfies and . For negative non-integers the reflection formula applies; has poles at
Trailing zeros (Legendre’s formula): the number of zeros at the end of is
Stirling’s approximation estimates large factorials: , with a relative error close to .
Worked example
- , and
- has 158 digits and ends with zeros; it is about
- and
- , and
Where factorials appear
- Arrangements: 8 runners can finish a race in different orders.
- Combinations: the number of ways to choose items from is ; a 6-from-49 lottery has possible draws.
- Probability: the chance that a shuffled deck of 52 cards is in one specific order is , about .
- Series: and
- Statistics: the Poisson and binomial distributions, and through the gamma function, the chi-square, Student and gamma distributions.
For very large factorials in formulas, work with logarithms: , which the gamma mode gives directly.
Why 0! equals 1
There is exactly one way to arrange an empty set: do nothing. The rule also forces it, since requires . And the gamma function agrees: . Without this convention, formulas such as would break.
Frequently asked questions
What is the largest factorial a normal calculator can show?
170! ≈ 7.257 × 10³⁰⁶ is the largest factorial that fits in a standard double-precision number; 171! ≈ 1.241 × 10³⁰⁹ overflows, which is why many calculators show an error. This calculator uses exact big-integer arithmetic and goes up to 1000!.
How many zeros are at the end of 100!?
Each trailing zero comes from a factor 10 = 2 × 5, and factors of 5 are the scarce ones. Count them with Legendre’s formula: ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24 zeros.
Can you take the factorial of a fraction or a negative number?
Not with the product definition, but the gamma function extends it: x! = Γ(x + 1). So (1/2)! = Γ(1.5) = √π / 2 ≈ 0.8862. Negative integers remain undefined, because Γ has poles at 0, −1, −2 and so on; other negative numbers do have a value, such as Γ(−0.5) ≈ −3.5449.
What is the difference between n!! and (n!)!?
n!! is the double factorial, the product of every other number: 9!! = 9 × 7 × 5 × 3 × 1 = 945. (n!)! is the factorial of a factorial, a vastly larger number: (3!)! = 6! = 720.
How accurate is the gamma function here?
For positive integers the result is exact, since Γ(n) = (n − 1)!. Elsewhere the calculator uses the Lanczos approximation published in Numerical Recipes, whose relative error is below 10⁻¹⁵; results are shown to 10 significant digits.
Sources
- NIST Digital Library of Mathematical Functions, §5.2 Gamma function — Definitions
- NIST DLMF §5.5 Functional relations (recurrence and reflection formulas)
- Press, Teukolsky, Vetterling & Flannery, Numerical Recipes, 3rd ed. (2007), §6.1 Gamma function
- OEIS A000142 — Factorial numbers
- OEIS A006882 — Double factorials
Last updated: