Exact BigInt for n up to 3,000Reviewed 28 Sep 2026Runs in your browser

Factorial Calculator

Compute n! exactly, plus double and multi-factorials, subfactorials and fractional factorials through the Gamma function — with trailing zeros, prime factorisation, digit count, and how close Stirling’s approximation gets.

Who wrote it

Written by Suhaib Hassan. The identities are standard number theory and analysis, and each worked example is re-derived by hand. Our methodology.

How the engine works

It multiplies with arbitrary-size integers, so there is no overflow at 170!. Prime exponents come from Legendre’s formula, and the Gamma function from a Lanczos approximation.

Why we built it

Factorials grow astonishingly fast. This page shows the exact value, its size, and why approximations work.

Standard factorial n!

Presets
0 to 3,000
Expansion—
10!—
—

—

Scientific notation—
Digits—

How fast factorials grow

log₁₀ of n! (blue) against Stirling’s approximation (orange) and eⁿ (grey, dashed). Factorials overtake any exponential.

—

Step-by-step working

—

—

    Factorial family reference

    Related functions, with values for n = 10.

    FunctionNotationDefinitionValue for n = 10Used for
    Factorialn!n·(n−1)·…·2·1, 0! = 13,628,800Permutations, series
    Double factorialn!!n·(n−2)·(n−4)·…3,840Integrals, spherical volumes
    Subfactorial!nn!·Σ(−1)ᵏ/k!1,334,961Derangements (no fixed points)
    Gamma functionΓ(z)∫₀^∞ t^(z−1) e^(−t) dtΓ(11) = 3,628,800Fractional factorials, statistics
    Falling factorial(n)ₖn!/(n−k)!(10)₃ = 720Ordered selections

    Worked examples

    Shuffling a deck

    How many orderings of a 52-card deck?

    52! ≈ 8.0658 × 10⁶⁷
    68 digits — far more than the number of seconds since the Big Bang, so a well-shuffled deck is almost surely in an order never seen before.

    Trailing zeros of 100!

    How many zeros end 100! ?

    ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24
    (there are always more factors of 2 than of 5)

    Fractional factorial

    What is (½)! ?

    (½)! = Γ(3/2) = ½ · Γ(½) = ½ √π
    = 0.886227

    What is a factorial?

    The factorial n! is the product of all whole numbers from 1 to n, with 0! = 1 by convention (there is exactly one way to arrange nothing). It counts the ways to order n distinct objects and grows faster than any exponential: 10! = 3,628,800 and 20! ≈ 2.43 × 10¹⁸.

    Useful facts

    • Trailing zeros (Legendre): the number of factors of a prime p in n! is Σ ⌊n/pᵏ⌋. Zeros equal the number of factors of 5.
    • Stirling’s approximation: n! ≈ √(2πn)(n/e)ⁿ, with relative error about 1/(12n).
    • Ramanujan’s refinement: n! ≈ √π (n/e)ⁿ (8n³ + 4n² + n + 1/30)^(1/6), far more accurate.
    • Gamma function: Γ(n + 1) = n!, extending factorials to real and complex numbers.

    By Suhaib Hassan · Reviewed 28 September 2026 · How CalculatePilot verifies formulas →

    Sources

    • NIST Digital Library of Mathematical Functions, chapter 5 (Gamma function), including 5.11 on asymptotic expansions.
    • Stirling, J. (1730). Methodus Differentialis. London.
    • Legendre, A.-M. (1808). Essai sur la théorie des nombres, 2nd ed. Paris — the prime-exponent formula.
    • Euler, L. (1729). Letter to Goldbach on the interpolation of factorials — origin of the Gamma function.

    Frequently asked questions

    Why is 0! equal to 1?

    Because there is exactly one way to arrange zero objects (do nothing), and because it keeps the recurrence n! = n · (n − 1)! true at n = 1 (1 = 1 · 0!). It also makes formulas such as C(n, 0) = n! ÷ (0! n!) = 1 work.

    How does Legendre’s formula count trailing zeros without multiplying everything?

    Each trailing zero needs one factor 10 = 2 × 5. Factors of 2 are more plentiful than 5s, so zeros equal the number of 5s in n!. Multiples of 5 contribute one each, multiples of 25 one more, multiples of 125 one more, and so on: Σ ⌊n/5ᵏ⌋.

    What is the difference between Stirling’s formula and Ramanujan’s correction?

    Stirling’s leading term underestimates n! by roughly 1/(12n) in relative terms (0.83% at n = 10). Ramanujan’s version adds a cubic term under a sixth root, shrinking the relative error to about 9 × 10⁻⁸ at n = 10 (under 0.00001%).

    How does this calculator avoid overflow?

    Ordinary 64-bit floating point overflows at 171! (about 10³⁰⁸). This page uses arbitrary-size integers for exact results up to 3,000!, and logarithms for the Stirling comparisons, so nothing overflows.

    Is the double factorial (n!!) the factorial of a factorial?

    No. n!! multiplies every second number down from n (10!! = 10 · 8 · 6 · 4 · 2 = 3,840). The factorial of a factorial would be (n!)!, which is astronomically larger.

    Can I take the factorial of a negative number or a fraction?

    Not with the whole-number definition. The Gamma function extends it to all real numbers except the negative integers, where it has poles: (−1)!, (−2)!, … are undefined. Use the Gamma tab for fractional values.

    Related calculators

    Continue with counting.

    All Math Calculators

    Embed This Factorial Calculator

    Free and responsive, and it runs in the visitor's browser. Branding removal from $7.99/month.

    <iframe src="https://www.calculatepilot.com/embed/factorial-calculator.html" width="100%" height="560" loading="lazy" title="Factorial Calculator"></iframe>
    For website owners

    Want this calculator on your own website?

    Embed it in one line of code. Keep it free with a small CalculatePilot attribution link, or go white-label: your brand, no attribution, one license for all your domains.

    • All 159 calculators, unlimited embeds
    • Works on WordPress, Webflow, Squarespace, Wix and plain HTML
    • Runs in your visitor's browser, so nothing is sent to a server
    • License key emailed automatically after checkout, cancel anytime
    $7.99 / month
    or $89.99 / year · white-label Pro
    Get the white-label license Embed free with attribution