Factorial Calculator
Compute n! (factorial) for any integer up to 170 (double precision limit). Above that, returns exact BigInt. Useful for combinatorics, probability and discrete math. Everything in your browser.
—
Factorial (n!)
The factorial of a non-negative integer n is the product of all positive integers up to n: n! = 1·2·3·…·n, with the convention 0! = 1 (justified by the gamma function). It grows very fast: 10! = 3,628,800; 13! already exceeds 6 billion (Int32 overflow); 20! ≈ 2.4×10¹⁸; 100! ≈ 9.33×10¹⁵⁷. For large n, Stirling's approximation is handy: n! ≈ √(2πn) · (n/e)^n. The gamma function extends factorial to real and complex numbers: Γ(n+1) = n!, which lets you compute things like (1/2)! = √π/2.
Applications and context
Factorials appear in combinatorics (C(n,k) = n! / (k!(n−k)!), A(n,k) = n! / (n−k)!), Taylor series (e^x = Σ x^n/n!), probability (poker hands, lottery odds like Mega-Sena), and algorithm complexity (brute-force Travelling Salesman is O(n!)). They're a staple of high-school combinatorial analysis (ENEM-style problems).
FAQ
Why is 0! equal to 1? By convention, so that formulas like C(n,0) = n!/(0!·n!) = 1 work. Gamma also gives Γ(1) = 1.
Is there a factorial of a negative number? Not for integers — the gamma function has poles at 0, −1, −2, …. But for non-integer negatives like −0.5, Γ is defined and finite.
How big can JavaScript handle exactly? Up to 18! using Number; beyond that you lose precision. Use BigInt for exact results past ~21!.
Related Tools
Rent Adjustment Calculator
Compute annual rent adjustment by IGP-M or IPCA accumulated in the last 12 months (manually configurable).
Pregnancy Calculator
Compute estimated due date (EDD), gestational age and trimester from the last menstrual period (LMP).
Fertile Period Calculator
Compute fertile window and ovulation day from the first day of the last cycle and the average cycle length.