Factorial Calculator

Calculate the factorial (n!) of a positive integer.

Factorial
120
5! = 5 × 4 × 3 × 2 × 1
Embed on your website →

How to use the factorial calculator

  1. Enter a positive integer.
  2. The factorial (n!) updates automatically.

What is factorial?

The factorial of a positive integer n, written n!, is the product of all positive integers up to and including n: n! = n × (n−1) × (n−2) × ... × 2 × 1. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. Factorial grows extremely quickly — already 20! is a 19-digit number.

Note: by definition, 0! = 1 (the product of "no numbers" is treated as 1, not 0). This calculator supports integers up to 170 — above that, the result becomes too large to represent precisely in JavaScript.

How fast factorials actually grow

Factorials grow faster than both exponential functions and powers, and it shows quickly in practice. 10! is a little over three and a half million, 20! passes two quintillion, and already there the number is too large for an ordinary 64-bit integer. Around 170! you exceed the range of a standard floating point number, and the computer simply answers «infinity».

That growth is why factorials turn up in combinatorics: the number of ways to arrange n items is exactly n!. A deck of 52 cards can be shuffled in 52! ways — a number with 68 digits, so large that any well-shuffled deck is overwhelmingly likely to be in an order that has never existed before.

Frequently asked questions

Why is 0! equal to 1, not 0?

Mathematically, factorial is defined as the product over an empty set of numbers when n = 0, and the empty product is by convention 1 (just as the sum of an empty set is 0). This choice also makes combinatorics formulas work correctly for n = 0.

What is factorial used for?

Factorial is fundamental in combinatorics — it's used to count the number of ways to arrange n objects (permutations), and appears in formulas for combinations and probability. See our combinatorics calculator for more on this.

Why does factorial grow so fast?

Because each new term is multiplied in rather than added — 10! is already 3,628,800, and 20! is over 2.4 × 10¹⁸. This rapid growth is called super-exponential.

Embed this calculator on your website

Copy the code below to show this calculator directly on your blog or website — completely free.