Factorial Calculator
Free factorial calculator supporting n!, double factorial (n!!), subfactorial (!n), and gamma function. Calculate large factorials with step-by-step solutions.
Common Factorial Values
Reference
n! = n × (n-1) × (n-2) × ... × 1
n!! = n × (n-2) × (n-4) × ...
!n = n! × Σ(-1)^k/k! for k=0 to n
Γ(n) = (n-1)! for positive integers
How to Use the Factorial Calculator
This calculator computes factorials and related functions including double factorial, subfactorial (derangements), and the gamma function.
Factorial (n!)
The factorial of n is the product of all positive integers from 1 to n.
Definition: n! = n × (n-1) × (n-2) × … × 2 × 1
Special cases:
- 0! = 1 (by convention)
- 1! = 1
Common Factorial Values
| n | n! |
|---|---|
| 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 |
| 12 | 479,001,600 |
| 15 | 1,307,674,368,000 |
| 20 | 2,432,902,008,176,640,000 |
Applications
- Counting arrangements (permutations)
- Binomial coefficients
- Probability distributions
- Taylor series
Double Factorial (n!!)
The double factorial multiplies every other integer from n down to 1 or 2.
Definition:
- For odd n: n!! = n × (n-2) × (n-4) × … × 3 × 1
- For even n: n!! = n × (n-2) × (n-4) × … × 4 × 2
Special cases:
- 0!! = 1
- 1!! = 1
- (-1)!! = 1
Examples
| n | n!! | Expansion |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 2 | 2 |
| 3 | 3 | 3 × 1 |
| 4 | 8 | 4 × 2 |
| 5 | 15 | 5 × 3 × 1 |
| 6 | 48 | 6 × 4 × 2 |
| 7 | 105 | 7 × 5 × 3 × 1 |
| 8 | 384 | 8 × 6 × 4 × 2 |
| 9 | 945 | 9 × 7 × 5 × 3 × 1 |
| 10 | 3,840 | 10 × 8 × 6 × 4 × 2 |
Relationship to Factorial
- For even n: n!! = 2^(n/2) × (n/2)!
- For odd n: n!! = n! / (n-1)!!
Subfactorial (!n) - Derangements
The subfactorial counts derangements: permutations where no element stays in its original position.
Definition: !n = n! × Σ((-1)^k / k!) for k = 0 to n
Recurrence: !n = (n-1) × (!(n-1) + !(n-2))
Examples
| n | !n | Probability |
|---|---|---|
| 0 | 1 | 100% |
| 1 | 0 | 0% |
| 2 | 1 | 50% |
| 3 | 2 | 33.3% |
| 4 | 9 | 37.5% |
| 5 | 44 | 36.7% |
| 6 | 265 | 36.8% |
| 7 | 1,854 | 36.8% |
| 8 | 14,833 | 36.8% |
| 10 | 1,334,961 | 36.8% |
Note: As n increases, the probability of a derangement approaches 1/e ≈ 36.79%
Applications
- Secret Santa problem
- Hat check problem
- Card shuffling analysis
Gamma Function Γ(n)
The gamma function extends the factorial to non-integer values.
Key property: Γ(n) = (n-1)! for positive integers
Relationship: Γ(n+1) = n × Γ(n)
Special Values
| x | Γ(x) |
|---|---|
| 1 | 1 |
| 2 | 1 |
| 3 | 2 |
| 4 | 6 |
| 5 | 24 |
| 1/2 | √π ≈ 1.7725 |
| 3/2 | √π/2 ≈ 0.8862 |
| -1/2 | -2√π ≈ -3.5449 |
Notable Formula
Γ(1/2) = √π
This means (−1/2)! = √π, extending factorials to half-integers!
Stirling’s Approximation
For large n, factorial can be approximated:
n! ≈ √(2πn) × (n/e)^n
| n | n! | Stirling Approx | Error |
|---|---|---|---|
| 5 | 120 | 118.02 | 1.7% |
| 10 | 3,628,800 | 3,598,696 | 0.8% |
| 20 | 2.43 × 10^18 | 2.42 × 10^18 | 0.4% |
Factorial Growth
Factorials grow extremely fast—faster than exponential!
| n | n! | 2^n | n^n |
|---|---|---|---|
| 5 | 120 | 32 | 3,125 |
| 10 | 3,628,800 | 1,024 | 10^10 |
| 20 | 2.43 × 10^18 | 1.05 × 10^6 | 10^26 |
Number of digits in n!: approximately n × log₁₀(n/e) + 0.5 × log₁₀(2πn)
- 100! has 158 digits
- 1000! has 2,568 digits
Related Resources
- Combinations Calculator - Uses factorials
- Counting Principles - Fundamentals
- Binomial Distribution - Probability application
Want to learn the theory?
Our lessons explain the statistical concepts behind this calculator with clear examples.
Browse Lessons →