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
Big Factorial (BigInt)
Compute n! up to 1000 with BigInt and show full result + digit count.
Combinations & Permutations
Calculate combinations C(n,k) and permutations P(n,k) with formulas and results for large numbers. Essential for combinatorics.
Power Calculator
Calculate the power aⁿ of any base and exponent, including negatives and decimals. Shows the result in scientific notation when necessary.
Arrangements A(n,k)
Compute arrangements A(n,k) (same as permutations).
Rule of Three Calculator
Solve a simple rule of three online. Enter three values and automatically calculate the fourth.
Math Expression Evaluator
Calculate math expressions as you type — sum, subtraction, multiplication, division, powers, square root, log, sin, cos, tan and parentheses. Shows the result. Everything in your browser.
The results provided by this tool are for general informational and educational purposes only and do not constitute professional, financial, medical, legal, tax or accounting advice. Always confirm important decisions with a qualified professional and official sources.