Factorial Calculator

Calculate factorials (n!), permutations P(n,r), and combinations C(n,r) with detailed explanations.

Calculator

Calculation Type:

5
0100

Maximum: 170 (larger values overflow)

Quick Values:

5!

120

Expansion:

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

🔢Digits
3
0️⃣Trailing Zeros
1

Related:

Double factorial (5!!):15
Subfactorial (!5):44

Common Factorials

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

Formulas

Factorial

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

0! = 1 by definition

Permutation

P(n,r) = n! / (n-r)!

Order matters

Combination

C(n,r) = n! / (r!(n-r)!)

Order doesn't matter

What is a Factorial?

A factorial, denoted by n!, is the product of all positive integers from 1 to n. Factorials are fundamental in mathematics, especially in combinatorics, probability, and calculus. The factorial function grows extremely rapidly, making it one of the fastest-growing common mathematical functions.

Definition:

  • n! = n × (n-1) × (n-2) × ... × 3 × 2 × 1
  • 0! = 1 (by definition)
  • 1! = 1
  • Factorials are only defined for non-negative integers

First Few Factorials:

n n! Calculation
01By definition
111
222 × 1
363 × 2 × 1
4244 × 3 × 2 × 1
51205 × 4 × 3 × 2 × 1
103,628,80010 × 9 × ... × 1

Factorial Formulas and Properties

Several important formulas and relationships involve factorials:

Key Factorial Formulas

Basic: n! = n × (n-1)! Recursive: n! = n × (n-1)! Permutations: P(n,r) = n! / (n-r)! Combinations: C(n,r) = n! / (r! × (n-r)!) Double Factorial: n!! = n × (n-2) × (n-4) × ... Odd: 7!! = 7×5×3×1 = 105 Even: 8!! = 8×6×4×2 = 384

Where:

  • n!= n factorial
  • P(n,r)= Permutations of n things taken r at a time
  • C(n,r)= Combinations of n things taken r at a time
  • n!!= Double factorial

Permutations and Combinations

Factorials are essential for counting arrangements and selections:

Concept Formula Order Matters? Example
Permutation P(n,r) = n!/(n-r)! Yes Arrange 3 books from 5: P(5,3) = 60
Combination C(n,r) = n!/(r!(n-r)!) No Choose 3 from 5: C(5,3) = 10
Full Permutation n! Yes Arrange 5 books: 5! = 120
With Repetition n!/(n₁!×n₂!×...) Yes Arrange "MISSISSIPPI"

Key Insight: Permutations = Combinations × (arrangements of selected items)

P(n,r) = C(n,r) × r!

How to Use This Factorial Calculator

Our factorial calculator computes factorials and related values quickly:

  1. Enter a Number: Input a non-negative integer (0 or positive whole number)
  2. Click Calculate: The calculator computes the factorial
  3. View Results:
    • The factorial value n!
    • Scientific notation for large results
    • Number of digits in the result
    • Step-by-step multiplication

Additional Features:

  • Permutations calculator: P(n,r)
  • Combinations calculator: C(n,r)
  • Double factorial: n!!
  • Subfactorial (derangements): !n

Important Notes:

  • Factorials grow extremely fast - 20! has 19 digits
  • Most calculators overflow around 170!
  • For very large n, use Stirling's approximation

Special Types of Factorials

Beyond the basic factorial, there are several related functions:

Double Factorial (n!!):

  • Product of every other integer from n down to 1 or 2
  • Odd: 7!! = 7 × 5 × 3 × 1 = 105
  • Even: 8!! = 8 × 6 × 4 × 2 = 384
  • 0!! = 1!! = 1

Subfactorial (!n) or Derangements:

  • Number of permutations where no element is in its original position
  • !n = n! × Σ((-1)^k / k!) from k=0 to n
  • Example: !4 = 9 (arrangements of ABCD where no letter is in its original spot)

Gamma Function Γ(n):

  • Extension of factorial to non-integers
  • Γ(n) = (n-1)! for positive integers
  • Γ(1/2) = √π
  • Allows "fractional factorials" like (0.5)!

Primorial (n#):

  • Product of all primes ≤ n
  • 7# = 2 × 3 × 5 × 7 = 210

Applications of Factorials

Factorials appear throughout mathematics and science:

Probability and Statistics:

  • Calculating probabilities of arrangements
  • Binomial coefficients in distributions
  • Expected value calculations

Combinatorics:

  • Counting permutations and combinations
  • Binomial theorem: (a+b)ⁿ expansion
  • Pascal's triangle entries

Calculus and Analysis:

  • Taylor series expansions: e^x = Σ(x^n / n!)
  • sin(x) = x - x³/3! + x⁵/5! - ...
  • Maclaurin series coefficients

Computer Science:

  • Algorithm complexity analysis
  • Brute force search space sizing
  • Cryptographic key space calculations

Real-World Examples:

  • How many ways can 10 people line up? 10! = 3,628,800
  • How many 5-card hands from 52 cards? C(52,5) = 2,598,960
  • Probability of a specific ordering in a deck of 52 cards: 1/52!

Stirling's Approximation

For large values of n, Stirling's approximation provides a way to estimate factorials:

Stirling's Approximation

n! ≈ √(2πn) × (n/e)^n More precise: n! ≈ √(2πn) × (n/e)^n × (1 + 1/(12n)) Log form (useful for calculations): ln(n!) ≈ n×ln(n) - n + ½×ln(2πn) Example: 10! Exact: 3,628,800 Stirling: ≈ 3,598,695 Error: ~0.8%

Where:

  • n= The number to compute factorial of
  • e= Euler's number ≈ 2.71828
  • π= Pi ≈ 3.14159

Worked Examples

Calculate a Basic Factorial

Problem:

Calculate 7!

Solution Steps:

  1. 1Write out the multiplication: 7! = 7 × 6 × 5 × 4 × 3 × 2 × 1
  2. 2Multiply step by step: 7 × 6 = 42
  3. 342 × 5 = 210
  4. 4210 × 4 = 840
  5. 5840 × 3 = 2,520
  6. 62,520 × 2 = 5,040
  7. 75,040 × 1 = 5,040

Result:

7! = 5,040

Permutation Problem

Problem:

How many ways can 4 students be arranged in a line from a class of 10?

Solution Steps:

  1. 1This is a permutation problem: P(n,r) = n!/(n-r)!
  2. 2n = 10 (total students), r = 4 (positions)
  3. 3P(10,4) = 10!/(10-4)! = 10!/6!
  4. 4= (10 × 9 × 8 × 7 × 6!)/6!
  5. 5= 10 × 9 × 8 × 7
  6. 6= 5,040

Result:

P(10,4) = 5,040 ways

Combination Problem

Problem:

How many ways can a committee of 3 be chosen from 8 people?

Solution Steps:

  1. 1This is a combination problem (order doesn't matter)
  2. 2C(n,r) = n!/(r!(n-r)!)
  3. 3C(8,3) = 8!/(3! × 5!)
  4. 4= (8 × 7 × 6 × 5!)/(3! × 5!)
  5. 5= (8 × 7 × 6)/(3 × 2 × 1)
  6. 6= 336/6 = 56

Result:

C(8,3) = 56 committees

Tips & Best Practices

  • Remember: 0! = 1 by definition, not 0
  • Factorials grow extremely fast - 20! already has 19 digits
  • Use the recursive property: n! = n × (n-1)! to build up from smaller factorials
  • For permutations (order matters): P(n,r) = n!/(n-r)!
  • For combinations (order doesn't matter): C(n,r) = n!/(r!(n-r)!)
  • Stirling's approximation works well for large n: n! ≈ √(2πn)(n/e)^n
  • Cancel common factors before calculating to simplify: 10!/8! = 10 × 9 = 90

Frequently Asked Questions

0! = 1 is defined this way for mathematical consistency. There's exactly one way to arrange zero objects: do nothing (the empty arrangement). It also ensures formulas work correctly: C(n,0) = n!/(0!×n!) = 1 (there's one way to choose nothing). The recursive formula n! = n × (n-1)! also requires 0! = 1 since 1! = 1 × 0! means 0! must equal 1.
Factorials grow faster than exponential functions because you're multiplying by increasingly larger numbers. While 2^n doubles each time, n! multiplies by n, then n+1, then n+2, etc. By 20!, you're multiplying by 20, giving a result with 19 digits. By 100!, the result has 158 digits. This 'super-exponential' growth makes factorials intractable for large n.
Standard calculators typically overflow around 69! or 70! (which has about 100 digits). Scientific calculators using floating point can go to about 170! before exceeding the maximum representable number. For larger factorials, you need arbitrary-precision arithmetic (big integer libraries) or use Stirling's approximation for estimates.
Permutations count ordered arrangements - ABC is different from CBA. Combinations count unordered selections - {A,B,C} is the same as {C,B,A}. Mathematically, P(n,r) = C(n,r) × r! because each combination can be arranged in r! ways. Use permutations when order matters (ranking, sequences) and combinations when it doesn't (committees, teams).
Factorials are only defined for non-negative integers (0, 1, 2, 3, ...). However, the Gamma function extends factorials to all complex numbers except negative integers. For positive numbers: Γ(n) = (n-1)! for integers, and Γ provides smooth values between integers. Notably, Γ(1/2) = √π, so (−1/2)! = √π.
A derangement is a permutation where no element appears in its original position. The number of derangements of n elements, written !n, equals approximately n!/e (rounded to nearest integer). For example, !4 = 9: the arrangements of ABCD where A isn't first, B isn't second, C isn't third, and D isn't fourth. Used in probability problems like the 'hat check' problem.

Sources & References

Last updated: 2026-01-22