Factorial Calculator

Calculate n! (factorial) for any non-negative integer. Useful for permutations, combinations, probability.

Factorial

What is Factorial?

Factorial of n (written n!) is the product of all positive integers from 1 to n. By definition, 0! = 1 (the empty product). Factorials grow extremely fast: 5! = 120, 10! ≈ 3.6 million, 20! ≈ 2.4 quintillion. Used in: permutations and combinations (combinatorics), probability calculations (dice, cards, lottery), series expansions (Taylor series, exponential function definition), statistics, computer science algorithm complexity (factorial-time algorithms are infeasible). Critical in any field involving counting arrangements or possibilities.

How to use this tool

  1. Enter non-negative integer — 0 to 170 (above 170 exceeds JavaScript precision).
  2. Calculate n! — Tool uses BigInt for arbitrary precision.
  3. View result — Full number plus scientific notation for huge values.
  4. Use in combinatorics formulas — n! is building block for permutations, combinations.

Factorial growth

n! = n × (n-1) × (n-2) × ... × 2 × 1

Growth examples:

  • 5! = 120
  • 10! = 3,628,800
  • 13! ≈ 6.2 billion
  • 15! ≈ 1.3 trillion
  • 20! ≈ 2.4 quintillion
  • 50! ≈ 3.0 × 10^64
  • 100! ≈ 9.3 × 10^157 (158 digits)
  • 170! ≈ 7.3 × 10^306 (JavaScript max double)

Applications:

  • Permutations: n! ways to arrange n distinct items
  • Combinations: n choose k = n! / (k!(n-k)!)
  • Taylor series: e^x = sum (x^n / n!)

Examples

  • 5! arrangements: 5 books on shelf can be arranged in 120 ways
  • 52! card shuffles: Number of unique deck orderings (mind-bogglingly huge)
  • n choose k: Combinations using n! / (k!(n-k)!)
  • Probability: Birthday paradox calculations involve factorials
  • Algorithm analysis: Traveling Salesman brute-force is O(n!) — infeasible for n > 12

Tips & best practices

  • Factorials grow MUCH faster than exponentials — quickly become huge
  • JavaScript handles up to 170! exactly with BigInt
  • For very large factorials, use Stirling's approximation: n! ≈ √(2πn)(n/e)^n
  • Permutations: nP_r = n! / (n-r)!
  • Combinations: nC_r = n! / (r!(n-r)!)

Frequently Asked Questions

Why is 0! = 1?

Defined this way to make formulas consistent. Empty product (multiplying zero numbers) = 1, similar to empty sum = 0. Also: 0! = 1 makes combinations formula (n choose 0 = 1) work correctly.

What's the largest factorial?

Theoretically: any non-negative integer has factorial. Practically: 170! is JavaScript's exact limit. Python or Java BigInteger handle arbitrary size.

Difference from exponential growth?

Exponential: a^n where base stays same. Factorial: 1×2×3×...×n where each factor grows. Factorial outpaces exponential for any base beyond small n.

Negative factorials?

Undefined for negative integers. For real numbers (including fractions and negatives), the Gamma function generalizes factorial: Γ(n+1) = n!

Why important in probability?

Counting arrangements (permutations) and selections (combinations) underlies probability. Factorial computes these counts.

Related tools

Probability Calculator · Scientific Calculator · Statistics Calculator

Copied