number theory calculators

Factorial Calculator

Compute the product of all positive integers up to a given number (n!). Essential for permutations, combinations, probability, and series expansion calculations.

About this calculator

The factorial of a non-negative integer n, written n!, is defined as the product n × (n−1) × (n−2) × … × 2 × 1, with the special case that 0! = 1 by convention. Formally: n! = ∏(i=1 to n) i. Factorials grow extraordinarily fast — 10! = 3,628,800 and 20! exceeds 2.4 × 10¹⁸. They appear throughout combinatorics: the number of ways to arrange n distinct objects is n!, the number of k-element combinations from n items is n! / (k! × (n−k)!), and factorial terms appear in Taylor series (e.g., eˣ = Σ xⁿ/n!). The calculator iterates from 2 to n, multiplying a running product at each step, and returns NaN for negative or non-integer inputs since factorial is only defined for non-negative integers.

How to use

Suppose you want to know how many ways 6 people can be seated in a row. You need 6!. Enter 6 in the Number field. The calculator computes 1 × 2 × 3 × 4 × 5 × 6 step by step: 1→2→6→24→120→720. The result is 720. As a second example, say you need 5! for a combination formula: enter 5, and get 1 × 2 × 3 × 4 × 5 = 120. Note: entering 0 correctly returns 1, and entering a negative number or decimal returns an error.

Frequently asked questions

Why is 0 factorial equal to 1?

0! = 1 is not an arbitrary rule — it is required for mathematical consistency. The most intuitive reason is that 0! counts the number of ways to arrange zero objects, and there is exactly one way to arrange nothing (do nothing). Formally, it follows from the recursive definition n! = n × (n−1)!: setting n = 1 gives 1! = 1 × 0!, so 0! must equal 1. It also ensures that combinatorial formulas like C(n, 0) = n! / (0! × n!) = 1 remain valid.

How fast do factorials grow compared to exponential functions?

Factorials grow faster than any fixed exponential function. While 2ⁿ doubles with each step, n! multiplies by an ever-increasing factor of n. By Stirling's approximation, n! ≈ √(2πn) × (n/e)ⁿ, which grows super-exponentially. In practical terms, 20! ≈ 2.4 × 10¹⁸, already exceeding the number of seconds since the Big Bang. This explosive growth is why even moderately sized permutation problems yield astronomically large numbers.

Where are factorials used in real-world probability calculations?

Factorials are central to counting problems in probability. The number of ordered arrangements (permutations) of n items is n!, while the number of unordered selections (combinations) of k items from n uses the formula C(n,k) = n! / (k! × (n−k)!). These appear in card game odds, lottery probabilities, DNA sequence analysis, and scheduling problems. Factorials also appear in the binomial theorem, Poisson distributions, and the Taylor expansions of sine, cosine, and the exponential function.