Factorial Calculator

Calculate n!, n!!, and subfactorials

CalculatorsFreeNo Signup
4.8(161 reviews)
All Tools

Loading tool...

About Factorial Calculator

A powerful factorial calculator supporting standard factorials (n!), double factorials (n!!), and subfactorials (!n / derangements). Handles values from 0! to 170! with standard precision and uses BigInt for exact results up to 10,000!. Shows the step-by-step multiplication expansion, counts the digits in the result, calculates the number of trailing zeros (from factors of 5), and presents Stirling's approximation for large values. Includes educational explanations of combinatorics applications. Essential for math students, probability learners, and competitive programmers.

Factorial Calculator Features

  • n! up to 10,000
  • BigInt exact results
  • Step-by-step expansion
  • Trailing zeros count
  • Double & sub-factorials
The factorial of a number n (written n!) is the product of all positive integers from 1 to n. It grows incredibly fast: 10! = 3,628,800 and 20! = 2,432,902,008,176,640,000. Factorials are fundamental to combinatorics (permutations, combinations), probability theory, Taylor series, and many areas of mathematics. This calculator computes exact factorials using BigInt, shows the expansion, counts digits, and analyzes trailing zeros.

How to Use the Calculator

Enter a non-negative integer and select the type:

  • n! — Standard factorial: 5! = 5×4×3×2×1 = 120
  • n!! — Double factorial: 5!! = 5×3×1 = 15 (product of same-parity numbers)
  • !n — Subfactorial/derangements: !5 = 44 (permutations with no fixed points)

How Fast Factorials Grow

Factorial growth is faster than exponential:

  • 5! = 120 (3 digits)
  • 10! = 3,628,800 (7 digits)
  • 20! = 2.43 × 10¹⁸ (19 digits)
  • 100! = 9.33 × 10¹⁵⁷ (158 digits)
  • 1000! has 2,568 digits
  • 10000! has 35,660 digits

Stirling's approximation: n! ≈ √(2πn) × (n/e)ⁿ gives accurate estimates for large n.

Trailing Zeros in Factorials

The number of trailing zeros in n! equals the number of times 10 divides n!, which is determined by the number of factor-5 pairs:

Trailing zeros = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + ⌊n/625⌋ + ...

For example, 100! has ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24 trailing zeros.

Step-by-Step Instructions

  1. 1Enter a non-negative integer (0 to 10,000).
  2. 2Select the mode: standard factorial, double factorial, or subfactorial.
  3. 3View the exact result (uses BigInt for precision).
  4. 4See the step-by-step expansion showing the multiplication chain.
  5. 5Check the digit count and trailing zeros analysis.

Factorial Calculator — Frequently Asked Questions

Why is 0! equal to 1?+

By convention and mathematical consistency: 0! = 1. This is the 'empty product' — the product of no numbers, which is defined as the multiplicative identity (1). It also ensures that the combination formula C(n,0) = n! / (0! × n!) = 1 works correctly, reflecting that there's exactly one way to choose 0 items.

What's the largest factorial this calculator can compute?+

Using BigInt, this calculator computes exact factorials up to 10,000! (which has 35,660 digits). Standard JavaScript Number precision is limited to 170! (after which it returns Infinity), but BigInt has no practical size limit. Results beyond 170! are displayed with full precision.

What are factorials used for?+

Factorials appear throughout mathematics: permutations (n! ways to arrange n items), combinations (C(n,k) = n! / (k!(n-k)!)), probability distributions (Poisson, binomial), Taylor series (eˣ = Σ xⁿ/n!), and derangements. In computer science, they define the complexity class of brute-force permutation algorithms.

Share this tool: