Factorial Calculator (n!)

Calculate the exact factorial of any non-negative integer, complete with full expansion, trailing zeros, permutations, and combinatorics.

Factorial Calculator (n!) — Product of all positive integers ≤ n
Quick n!:

Comparative Growth: Factorial (n!) vs Exponential (2ⁿ) vs Polynomial (n³)

Logarithmic Scale (log₁₀)

Notice how factorials outpace all polynomial and standard exponential rates. While 10³ = 1,000 and 2¹⁰ = 1,024, 10! reaches 3,628,800.

Mastering Factorials (n!) in Modern Mathematics & Computation

The factorial function is one of the most fundamental operations in discrete mathematics, probability theory, statistics, computer science algorithm analysis, and quantum physics. Written as an integer followed by an exclamation mark (such as 6!), the factorial represents the product of all positive integers from 1 up to n.

Mathematical Properties of n!

Factorials exhibit unique mathematical properties that make them essential in combinatorics and analysis:

  • Recurrence Relation: n! = n × (n - 1)! for all n ≥ 1.
  • Empty Product Identity: 0! = 1. This allows combinatorial formulas such as C(n, 0) = n! / (0! × n!) = 1 to hold true universally.
  • Gamma Function Extension: The factorial function can be extended to all complex and real numbers (except negative integers) through Euler's Gamma Function: Γ(n + 1) = n!. For example, (1/2)! = Γ(3/2) = √π / 2 ≈ 0.8862.
  • Legendre's Formula for Prime Divisors: The exponent of any prime p dividing n! is given by E_p(n!) = ⌊n/p⌋ + ⌊n/p²⌋ + ⌊n/p³⌋ + .... This efficiently determines trailing zeros by calculating the multiplicity of prime factor 5.

Permutations and Combinations

Factorials are the backbone of counting and probability:

Permutations P(n, r) = n! / (n - r)! — The number of ways to arrange r items from a collection of n where sequence/order is critical.

Combinations C(n, r) = n! / [r!(n - r)!] — The number of unordered subsets of size r from n items.

Frequently Asked Questions (FAQ)

How does a factorial calculator handle extremely large numbers?
Standard JavaScript 64-bit floating-point numbers overflow to Infinity above 170! (approx 7.257 × 10³⁰⁶). This calculator utilizes native arbitrary-precision BigInt arithmetic, enabling exact digit-by-digit computation for factorials up to 2000! without loss of numeric precision.
How many trailing zeros does 100! have?
Using Legendre's formula for p = 5: ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24 trailing zeros. The number 100! terminates in exactly 24 zeros and contains 158 digits.

Calculation History