Factorial & Gamma Function Calculator

Enter a whole number for the full decimal factorial, its prime factorization, digit count and trailing zeros. Compare Stirling's estimate with mathematical error bounds. Switch to real gamma to inspect its continuation between poles, sign changes and magnitudes that exceed ordinary floating-point values.

Factorials and special functions

Explore factorials and gamma

Whole numbers from 0 to 2,000.

25 factorial

15,511,210,043,330,985,984,000,000

Exact decimal length
26 digits
Trailing zeros
6

Factorial growth

Each vertical unit means a tenfold change in size. The point marks the entered factorial.

Factorial growth on a logarithmic scaleThe common logarithm of factorial increases as more factors are multiplied. Exact digits appear below the chart.log₁₀(n!)014.128.201225Factorial argument (n)

Stirling shortfall

0.332760684%

Rounded Robbins bounds · 0.331674654% to 0.3327783945%.

Shortfall is relative to the exact factorial.

Exact value and prime powers

Prime powers

  • 2 to the power 22
  • 3 to the power 10
  • 5 to the power 6
  • 7 to the power 3
  • 11 to the power 2
  • 13 to the power 1
  • 17 to the power 1
  • 19 to the power 1
  • 23 to the power 1

Import the exact factorial column as text to preserve every digit in a spreadsheet.

Select calculation CSV

How to use this calculator

  1. Enter an integer from 0 to 2,000 in Factorial. Open Exact value and prime powers to inspect the complete digits and factorization.
  2. Compare the logarithmic growth chart with the exact digit count. Review the relative shortfall of Stirling's approximation and the Robbins bounds.
  3. Switch to Real gamma and enter a decimal argument between −20 and 200. Inspect the value, sign and log magnitude or the two one-sided directions at a pole.
  4. Use Near a gamma pole and compare arguments on either side of −2. The chart separates branches at every pole and clips magnitudes at its visible limits.
  5. Download the active mode's CSV or copy its selectable text. Treat the exact decimal factorial field as text when importing into a spreadsheet.

The Formula

The mathematical logic powering this calculation is:

For integer n ≥ 0, n! is the product of the integers 1 through n, with 0! = 1. The calculator multiplies exactly using arbitrary-precision integers. In n!, the exponent of a prime p is ⌊n/p⌋ + ⌊n/p²⌋ + ⋯, since each multiple of p contributes at least once and multiples of higher powers contribute again. Each decimal trailing zero uses a pair of factors 2 and 5. The exponent of 5 is the smaller count for n!, so it gives the trailing-zero count. The digit count comes from the exact decimal value and the growth chart shows numerical log₁₀(n!).

For n ≥ 1, the uncorrected Stirling estimate is S = √(2πn)(n/e)ⁿ. Robbins shows n! = S exp(r) with 1/(12n+1) < r < 1/(12n). The displayed relative shortfall is 100(1−S/n!) percent. Apply 100(1−exp(−r)) to both Robbins endpoints for its strict lower and upper bounds. At n ≥ 12, the numerical shortfall uses the log-gamma correction series directly to avoid cancellation between large logarithms. At smaller positive n it subtracts the Stirling log from the accumulated log factorial. Displayed decimals are approximations; the strict inequality concerns the mathematical endpoints. The Stirling comparison starts at n = 1.

Gamma satisfies Γ(x+1) = xΓ(x), with Γ(n+1) = n! and Γ(1/2) = √π. At positive x, log-gamma uses the DLMF asymptotic expansion through the term in x⁻¹³, shifting the argument to at least 12 by recurrence. At negative nonintegers it uses Γ(x)Γ(1−x) = π/sin(πx). Input decimals are counted in exact 10⁻¹² units to detect poles and evaluate the sine from the distance to the nearest integer. Zero and negative integers are simple poles. At x = −m their residue is (−1)^m/m!, so the limits have opposite signs on the two sides. The graph shows log₁₀|Γ(x)| and uses line style to encode the sign. It samples branches independently and has finite axis limits.

The exact integer mode accepts 0–2,000. The real gamma mode accepts −20 to 200 with up to twelve decimal places. Gamma calculations use double precision and display approximately eight significant digits. Accuracy is checked against analytic fixtures and high-precision reference values, with separate treatment near poles. The numerical values are for the entered decimal argument; a small change to an argument near a pole may greatly change the result. Complex arguments are outside this real-valued model.

Worked Example

If you input:

  • Factorial argument n: 25
  • Gamma argument x: −1.5

Result:

25! = 15,511,210,043,330,985,984,000,000. It has 26 digits and 6 trailing zeros. Γ(−1.5) = 4√π/3 ≈ 2.3632718.

Frequently Asked Questions

Why does zero factorial equal one?

The product over zero factors is one. This also gives a single way to arrange zero objects and agrees with Γ(1) = 1.

How can I count trailing zeros without writing out the factorial?

Count the factors of 5 in n!: add the quotients rounded down for 5, 25, 125 and higher powers. There are enough factors of 2 to pair with each 5.

Why does Stirling's approximation underestimate n!?

The exact factorial includes an additional positive exponent correction. The Robbins inequalities bound that correction on both sides.

What does a negative value on the gamma chart mean?

A negative log magnitude means |Γ(x)| is below one. Solid and dashed line styles separately indicate the sign of Γ(x).

What happens at x = 0 or a negative integer?

Gamma has a simple pole. The value is undefined there and its limits from the left and right have opposite signs.

What does a factorial of a negative or fractional number mean?

The integer factorial is defined for nonnegative integers. For other real arguments where it is finite, the usual continuation is Γ(n+1). Enter n+1 in Real gamma.

Similar Calculators