Math calculator

Free factorial calculator

Calculate the factorial of any non-negative integer — enter n to see n! and understand its use in permutations and combinations, updated live, as you type.

InputsLive
n (non-negative integer)
Enter a whole number from 0 to 170.
Result
n!
3,628,800
10! = 3.6288e+6
n10
Result3.6288e+6
Overflowed?No
Max exact n170

n! = n × (n−1) × … × 2 × 1. 0! = 1. Overflows to ∞ for n > 170.

Results are estimates. Consult a professional.

How it's calculated

How the factorial calculator works

The factorial of a non-negative integer n, written n!, is the product of all positive integers from 1 up to n. Factorials grow extremely fast and are the foundation of combinatorics — counting permutations, combinations, and probability arrangements.

n! = n × (n1) × (n2) ×× 2 × 1
0! = 1 (by definition — the empty product)
Stirling's approximation (large n): n! ≈ √(2πn) × (n/e)ⁿ

The convention 0! = 1 is not arbitrary — it ensures that combinatorial formulas like C(n, 0) = 1 work consistently. Stirling's approximation is useful for mental estimates when n is large but exact computation is unnecessary.

NIST Digital Library of Mathematical Functions — §5.2 Gamma Function
Example

Worked example: 5! and 10!

Example: 5! and 10!

How many ways can you arrange 5 books on a shelf? And how large does 10! get?

5! = 5 × 4 × 3 × 2 × 1 = 120
10! = 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 3,628,800
5! = 120 · 10! = 3,628,800
120 ways to arrange 5 books — and over 3.6 million ways to arrange just 10 items. Factorials explode quickly.
Quick reference

Factorials from 0! to 12!

The table below lists exact factorial values up to 12!, which is the largest factorial that fits in a standard 32-bit integer.

nn!Approximate
011
111
222
366
42424
5120120
6720720
75,0405.04 × 10³
840,3204.03 × 10⁴
9362,8803.63 × 10⁵
103,628,8003.63 × 10⁶
1139,916,8003.99 × 10⁷
12479,001,6004.79 × 10⁸

12! = 479,001,600 — the largest factorial below 2³² (≈ 4.29 × 10⁹). 13! exceeds 32-bit integer range.

Practical tips

Tips for working with factorials

Factorials appear most often in combinatorics and probability. These tips prevent common errors.

  • Remember 0! = 1 — this is defined, not calculated; it ensures formulas like C(n, 0) = n!/(0! × n!) = 1 are consistent.
  • Factorials only apply to non-negative integers — n! is not defined for negative integers or fractions (though the Gamma function extends factorials to real numbers).
  • Cancel common factors before multiplying — in C(10, 3) = 10!/(3! × 7!), cancel the 7! from numerator and denominator to get (10×9×8)/(3×2×1) = 120 without computing huge numbers.
  • Use logarithms for large factorials — log(n!) = Σ log(k) for k = 1 to n; this avoids overflow and is how calculators handle 100! and beyond.
  • Permutations vs combinations — P(n, r) = n!/(n−r)! counts ordered arrangements; C(n, r) = n!/(r!(n−r)!) counts unordered selections.
Accuracy & limits

Accuracy and limitations

This calculator returns exact integer results for n ≤ 18 (the range that fits in a 64-bit integer). For n from 19 to approximately 170, results use double-precision floating-point and are accurate to about 15 significant digits — the trailing digits of very large factorials may be rounded. Beyond 170!, the result exceeds the maximum double-precision value (~1.8 × 10³⁰⁸) and the calculator returns the result in logarithmic form (log₁₀(n!)) to prevent overflow.

Glossary

Key terms

The product of all positive integers from 1 to n; by convention 0! = 1.
The number of ordered arrangements of r items chosen from n distinct items; P(n,r) = n!/(n−r)!.
The number of unordered selections of r items from n; C(n,r) = n!/(r!(n−r)!). Also written ⁿCᵣ or "n choose r".
A formula for estimating large factorials: n! ≈ √(2πn)(n/e)ⁿ; error is less than 1% for n ≥ 10.
A continuous extension of factorials to real numbers; Γ(n) = (n−1)! for positive integers.
The mathematical convention that a product with zero factors equals 1; the reason 0! = 1.
About

About this calculator

Part of our math calculators suite — explore all calculators.

Questions

Frequently asked questions about the free factorial calculator

A factorial calculator is a free online tool that helps you compute n! — the product of all positive integers up to n. Factorial is the product of all positive integers from 1 to n. It grows extremely fast — 13! already exceeds a billion, and 170! is the largest JavaScript can represent exactly. It runs entirely in your browser with instant results and no sign-up.
By convention, defined to make formulas like C(n, 0) = 1 work consistently. Mathematically: the empty product is 1 (like the empty sum is 0). And there's exactly one way to arrange zero objects — do nothing. So 0! = 1 makes sense both definitionally and combinatorially.
Faster than any exponential. 10! ≈ 3.6 million. 20! ≈ 2.4 quintillion. 100! has 158 digits. 170! ≈ 7.3 × 10³⁰⁶, the largest n! that fits in a double-precision float; 171! overflows to Infinity.
Yes — the gamma function Γ(n + 1) generalizes factorial to all real and complex numbers (except non-positive integers). Γ(0.5 + 1) = Γ(1.5) = (√π)/2, for instance. This calculator only handles non-negative integers.

Want a calculator built for your business?

Customize any of our 400+ tools to match your brand, or commission a new one tailored to how your business actually calculates — pricing, payroll, quotes, anything. Deployed on your domain, math runs in your visitors' browsers.