Factorial Calculator

Calculate n! for any integer from 0 to 170 instantly. Full precision via BigInt, step-by-step product expansion and scientific notation.

Enter a whole number from 0 to 170. (170! ≈ 7.26 × 10306)

This free factorial calculator computes n! for any whole number from 0 to 170, instantly and with exact precision. Type a number — or tap one of the quick buttons (5!, 10!, 20!, 50!, 100!) — and you get the full value, its digit count, scientific notation and a step-by-step expansion. Below we explain what a factorial is, the factorial formula and where factorials are used.

What Is a Factorial?

A factorial is the product of all positive integers from 1 to n, written n! and read "n factorial". For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. By definition 0! = 1. Factorials are the foundation of combinations, permutations and probability calculations, so they appear throughout mathematics, statistics and computer science.

Factorials grow extremely fast — faster than any exponential. 10! = 3,628,800; 20! ≈ 2.43 × 10¹⁸; and 100! already has 158 digits. Because ordinary number types lose precision well before this point, this tool uses JavaScript BigInt to compute every digit exactly, all the way up to 170!.

The Factorial Formula

The factorial formula can be written two equivalent ways, and this calculator follows both — iterating through the product and showing each step:

  • Iterative: n! = n × (n−1) × (n−2) × … × 2 × 1
  • Recursive: n! = n × (n−1)! (base case: 0! = 1)

The recursive form is why 0! must equal 1: setting 1! = 1 × 0! forces 0! = 1, which keeps every later formula (like combinations and permutations) consistent.

Factorial Table (0! – 15!)

nn! (Value)DigitsUse case
0!11Empty-set permutation
1!11Single-item arrangement
5!1203Seating 5 people
7!5,0404Fixture for 7 teams
10!3,628,8007Combination calculations
12!479,001,6009Clock combinations
15!1,307,674,368,00013Cryptography

Real-World Uses of Factorials

  • Combinations C(n,r): How many ways to choose r items from n? C(n,r) = n! / (r! × (n−r)!). Example: choose 5 cards from a 52-card deck → C(52,5) = 2,598,960.
  • Permutations P(n,r): How many ordered arrangements of r items from n? P(n,r) = n! / (n−r)!. Example: gold, silver, bronze from 8 athletes → P(8,3) = 336.
  • Probability distributions: Binomial, Poisson and hypergeometric distributions all use n!.
  • Cryptography: RSA and other algorithms rely on the enormous size of factorials to guarantee security.
  • Algorithm complexity: O(n!) algorithms (e.g. brute-force travelling salesman) are impractical even for moderate n — illustrating why factorial growth matters.

Special Cases and Notes

  • 0! = 1 by definition — the empty set has exactly one permutation.
  • Trailing zeros in n!: The count is ⌊n/5⌋ + ⌊n/25⌋ + … Example: 100! ends in 24 zeros.
  • Stirling's approximation for very large n: n! ≈ √(2πn) × (n/e)ⁿ.
  • Overflow: Standard 64-bit integers overflow at 21!. This tool uses BigInt for exact results up to 170!.

What Is the Sum of Factorials?

The sum of factorials adds successive factorial values together: 1! + 2! + 3! + … + n!. It appears in number theory and some series problems. For example, 1! + 2! + 3! + 4! = 1 + 2 + 6 + 24 = 33. The values rise so quickly that the last term almost always dominates the total — by 1! + … + 10! the sum is 4,037,913, and the 10! term alone (3,628,800) makes up about 90% of it. To work out a sum of factorials, calculate each n! with the tool above and add the results.

How to Calculate a Factorial Step by Step

Calculating a factorial by hand is straightforward; this tool simply automates and verifies the steps:

  1. Start at the number n you want the factorial of (for example, 6).
  2. Multiply by each smaller whole number in turn: 6 × 5 × 4 × 3 × 2 × 1.
  3. Stop at 1 — and remember 0! and 1! both equal 1.
  4. Read the result: 6! = 720. The calculator also shows the digit count and scientific notation for very large results.

For big inputs, doing this by hand becomes impractical fast, which is exactly where an exact-precision factorial calculator helps. Enter any number from 0 to 170 above to see the full expansion and result.

Factorials in Combinations and Permutations

The most common practical reason to compute a factorial is to count arrangements and selections. Both core counting formulas are built on n!:

  • Permutations count ordered arrangements: P(n, r) = n! ÷ (n − r)!. The order matters, so first, second and third place are all different outcomes.
  • Combinations count unordered selections: C(n, r) = n! ÷ (r! × (n − r)!). Here only the group matters, not the order within it.

For instance, choosing a 3-person committee from 10 people is a combination: C(10, 3) = 120. But ranking the top 3 of those 10 is a permutation: P(10, 3) = 720 — six times more, because each group of three can be ordered in 3! = 6 ways. Understanding this difference is the heart of probability and statistics, and it is why a reliable factorial calculator is such a useful starting point.

How Fast Do Factorials Grow?

Factorial growth outpaces even exponential growth, which is why it shows up in discussions of computational difficulty. Compare doubling (2ⁿ) with the factorial of the same n: at n = 5, 2⁵ = 32 while 5! = 120; at n = 10, 2¹⁰ = 1,024 while 10! = 3,628,800. By n = 20 the factorial is already astronomically larger. This explosive growth is the reason "brute-force" algorithms that try every ordering — such as checking every possible route in the travelling-salesman problem — become impossible for even moderately sized inputs, and it is also why large factorials need exact BigInt arithmetic rather than ordinary floating-point numbers.

Frequently Asked Questions About the Factorial Calculator

A factorial is the product of all positive integers from 1 to n, written n!. For example, 5! = 5×4×3×2×1 = 120. By definition 0! = 1. Factorials are the foundation of combinations, permutations and probability.

Iterative: n! = n × (n−1) × … × 2 × 1. Recursive: n! = n × (n−1)! with base case 0! = 1. Combination C(n,r) = n!/(r!×(n−r)!); permutation P(n,r) = n!/(n−r)!.

By mathematical definition. The empty set has exactly one permutation. It also keeps formulas like C(n,0) = 1 consistent.

Standard factorial is only defined for non-negative integers. The Gamma function extends it to non-integers: n! = Γ(n+1). This tool supports integers 0–170.

n! = P(n,n) — arranging all n items. P(n,r) = n!/(n−r)! arranges only r items from n. Factorial is the special case where all items are used.

100! has 158 digits. You can verify with the digit count shown by this calculator, or estimate using Stirling's approximation: log₁₀(n!) ≈ n·log₁₀(n/e) + 0.5·log₁₀(2πn).

Couldn't find the answer you were looking for?

Explore all our tools and get the fastest answer to your question.

Go to All Tools