Anantastra Tools

Free, privacy-focused utilities for your everyday needs

Calculators

Financial and mathematical calculation tools to help with your computations

Factorial Calculator

Understanding Factorials

What is a Factorial?

The factorial of a non-negative integer n, denoted as n!, is the product of all positive integers less than or equal to n.

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

Special cases:

  • 0! = 1 (by mathematical definition)
  • 1! = 1

Examples

  • 2! = 2 × 1 = 2
  • 3! = 3 × 2 × 1 = 6
  • 4! = 4 × 3 × 2 × 1 = 24
  • 5! = 5 × 4 × 3 × 2 × 1 = 120

Stirling's Approximation

For large values of n, computing the exact factorial becomes difficult due to the rapid growth. Stirling's formula provides an approximation:

n! ≈ √(2πn) × (n/e)n

where e is the mathematical constant approximately equal to 2.71828.

Applications of Factorials

  • Combinations and Permutations: Used to calculate the number of ways to arrange or select items.
  • Probability Theory: Essential for calculating various probability distributions.
  • Series Expansions: Used in Taylor series and other mathematical expansions.
  • Number Theory: Important in various number theory problems and formulas.
  • Statistical Distributions: Used in defining distributions like the Poisson distribution.

Did you know?

Factorials grow extremely quickly! 20! has 19 digits, 50! has 65 digits, and 100! has 158 digits. The largest factorial that can be represented exactly as a JavaScript number is 170! - beyond that, the precision is lost and approximations must be used.

Recursive Definition

Factorials can be defined recursively as:

n! = n × (n-1)!
0! = 1

This recursive definition is often used in programming implementations.