Factorial Calculator

Calculate factorials (n!) for any positive integer. Get instant results with step-by-step calculations and understand the mathematical properties of factorials.

!
Factorial Definition:
• n! = n × (n-1) × (n-2) × ... × 2 × 1
• 0! = 1 (by definition)
• 1! = 1
• Factorials grow very rapidly
• Used in permutations, combinations, and probability
• Maximum calculable: 170! (due to JavaScript limits)

Calculation Results

Factorial Expression:
5! = 120
Decimal Value:
120
Scientific Notation:
1.200 × 10²
Step-by-Step Calculation:
5! = 5 × 4 × 3 × 2 × 1
= 20 × 3 × 2 × 1
= 60 × 2 × 1
= 120 × 1
= 120
Number of Digits:
3 digits

Understanding Factorials and Their Applications

What are Factorials?

A factorial, denoted as n!, is the product of all positive integers from 1 to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. Factorials are fundamental in mathematics, particularly in combinatorics, probability theory, and calculus, where they appear in formulas for permutations, combinations, and series expansions.

Factorial Properties

Factorials have several important properties: 0! = 1 by definition, factorials grow extremely rapidly (faster than exponential functions), and they are only defined for non-negative integers. The rapid growth means that even relatively small numbers like 170! exceed the limits of standard computer arithmetic.

Mathematical Relationships

  • Recursive definition: n! = n × (n-1)!
  • Stirling's approximation: n! ≈ √(2πn) × (n/e)ⁿ
  • Gamma function: n! = Γ(n+1)
  • Double factorial: n!! = n × (n-2) × (n-4) × ...
  • Subfactorial: !n (derangements)
  • Rising factorial: (x)ₙ = x(x+1)...(x+n-1)

Growth Rate

Factorials grow faster than exponential functions. While 2ⁿ grows exponentially, n! grows super-exponentially. This rapid growth makes factorials useful in analyzing algorithm complexity and understanding combinatorial explosion.

Factorial Applications

Combinatorics

Factorials are essential for calculating permutations (n!/(n-r)!) and combinations (n!/(r!(n-r)!)). They determine the number of ways to arrange or select objects, fundamental in probability theory and discrete mathematics.

Calculus and Analysis

Taylor and Maclaurin series use factorials in their denominators. The exponential function eˣ = Σ(xⁿ/n!), sine and cosine functions, and many other important series rely on factorial terms for their expansions.

Computer Science

Algorithm analysis often involves factorial time complexity O(n!), particularly in problems like the traveling salesman problem. Factorials also appear in recursive algorithms and dynamic programming solutions.

Factorial Examples and Patterns

Small 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

Large Factorials

As numbers increase, factorials become astronomically large. 20! has 19 digits, 50! has 65 digits, and 100! has 158 digits. The largest factorial that can be computed in standard JavaScript is 170!, which has 308 digits.

Practical Limits

Due to the rapid growth of factorials, computational limits are quickly reached. For practical applications involving large numbers, approximations like Stirling's formula or logarithmic representations are often used instead of exact calculations.