Factorial Calculator

Calculate factorials (n!), double factorials (n!!), subfactorials (!n), and Stirling's approximation

Calculate Factorial Functions

Enter any non-negative integer (0 to 170 for regular factorial)

Choose the type of factorial calculation

Function Definitions:

Factorial (n!):Product of all positive integers from 1 to n. Example: 5! = 5 × 4 × 3 × 2 × 1 = 120
Double Factorial (n!!):Product of all positive integers up to n that have the same parity. Example: 5!! = 5 × 3 × 1 = 15
Subfactorial (!n):Number of derangements of n objects. Example: !4 = 9 (ways to arrange 4 items so none is in original position)
Stirling's Approximation:Approximation formula: n! ≈ √(2πn) × (n/e)ⁿ. Very accurate for large n.

Common Factorial Values

0!1
1!1
2!2
3!6
4!24
5!120
6!720
7!5,040
8!40,320
9!362,880
10!3,628,800

Factorial Tips

0! = 1 by mathematical convention

Factorials grow extremely quickly

Used in permutations and combinations

Double factorials skip every other number

Subfactorials count derangements

Stirling's formula is very accurate for large numbers

Understanding Factorials and Related Functions

What is a Factorial?

The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. It's fundamental in combinatorics, probability, and many areas of mathematics.

Mathematical Definition:

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

For n ≥ 1, and 0! = 1 by definition

Why is 0! = 1?

This is defined by mathematical convention to make formulas work consistently. It ensures that the recursive formula n! = n × (n-1)! holds for all positive integers.

Applications in Mathematics

Permutations

Number of ways to arrange n objects: P(n,r) = n!/(n-r)!

Combinations

Number of ways to choose r objects from n: C(n,r) = n!/(r!(n-r)!)

Probability Theory

Calculating probabilities in discrete distributions

Calculus

Taylor series expansions and power series

Factorial Variations

Regular Factorial (n!)

Standard factorial function

5! = 5 × 4 × 3 × 2 × 1 = 120

Double Factorial (n!!)

Product with same parity numbers

5!! = 5 × 3 × 1 = 15

Subfactorial (!n)

Number of derangements

!4 = 9

Stirling's Approximation

For large values of n, calculating n! exactly becomes computationally intensive. Stirling's approximation provides a very accurate estimate:

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

This approximation becomes increasingly accurate as n grows larger, with the relative error approaching zero.