How factorial calculator works
The factorial of a non-negative integer n, written as n!, is the product of all positive integers less than or equal to n. For example, 5! = 5 times 4 times 3 times 2 times 1 = 120. By convention, 0! = 1.
Factorials grow extremely fast. 10! is already 3,628,800, and 20! exceeds 2 quintillion. JavaScript can represent factorials up to 170! before exceeding the maximum representable floating-point number.
Factorials are fundamental in combinatorics and probability. They count the number of ways to arrange n distinct objects (permutations), and appear in binomial coefficients, the Poisson distribution, and Taylor series expansions.
Frequently asked questions
What is a factorial?
The factorial of n (written n!) is the product of all positive integers from 1 to n. For example, 5! = 5 times 4 times 3 times 2 times 1 = 120. By convention, 0! = 1.
What is the largest factorial I can calculate?
This calculator handles up to 170!, which is the largest factorial representable in JavaScript double-precision floating-point. Beyond that, the result overflows to infinity.
Why is 0! equal to 1?
By definition, 0! = 1. This is a mathematical convention that makes formulas work correctly, particularly in combinatorics where the number of ways to arrange zero objects is defined as 1 (the empty arrangement).
What are factorials used for?
Factorials count permutations (arrangements) of objects. They appear in probability (binomial coefficients), combinatorics, calculus (Taylor series), and the Poisson distribution. n! gives the number of ways to arrange n distinct items.