Current for 2026As of: July 2026

Factorial Calculator calculate n!.

Instantly calculate 0! to 170! – with permutation and combinatorics explanations

FreeNo sign-upGDPR-compliant

Factorial Calculator

Calculate n! – from 0! to 170!

0 20

5!

120

5! = 120

The factorial – basics and applications

From the definition to combinatorics and probability theory

The factorial n! (read "n factorial") is the product of all positive integers from 1 to n. The values grow extremely fast: 5! = 120, 10! = 3,628,800, 20! ≈ 2.43 × 10¹⁸ – that exceeds the number of seconds since the Big Bang. No wonder the factorial is so important in combinatorics: it counts the number of ways to arrange (permutations) n distinguishable objects.

The most important example: how many ways are there to seat 5 people at a table? The first person can sit in 5 chairs, the second in 4 remaining ones, and so on. That gives 5 × 4 × 3 × 2 × 1 = 5! = 120. The same logic applies to permutations in statistics, sequencing optimization (the travelling salesman problem) and calculating binomial coefficients: (n choose k) = n! / (k! × (n−k)!).

The special case 0! = 1 is defined by mathematical convention and follows from the recursion formula n! = n × (n−1)!: for n = 1, 1! = 1 × 0! = 1, so 0! must equal 1. It also makes intuitive sense: there is exactly one way to arrange zero elements – the empty arrangement. Without this convention, formulas like the binomial coefficient would not work for k = 0 and k = n.

In probability theory, the factorial determines how many outcomes are possible when drawing without replacement. If 6 numbers are drawn out of 49 (lottery), the number of possibilities is calculated with the binomial coefficient (49 choose 6) = 49! / (6! × 43!) ≈ 13,983,816. The huge numbers arise because factors like 49! become astronomically large but largely cancel out in the fraction. Our calculator computes factorials iteratively, which delivers precise IEEE 754 results for numbers up to 170.

Calculation examples

Calculate 5!

Calculate 5!
ItemAmount
n5
Formula5 × 4 × 3 × 2 × 1
Result120

0! and 1! (special cases)

0! and 1! (special cases)
ItemAmount
0! by definition1
1! = 1 × 0!1 × 1 = 1

Frequently asked questions about the factorial calculator

Definitions, applications and mathematical background

The factorial of a non-negative integer n (written n!) is the product of all positive integers from 1 to n. Formally: n! = 1 × 2 × 3 × … × n. Examples: 5! = 120, 10! = 3,628,800. Special cases: 0! = 1 and 1! = 1 (by definition). The factorial grows extremely fast: 20! ≈ 2.4 × 10¹⁸.

The convention 0! = 1 follows from several mathematical consistency arguments: (1) The recursion formula n! = n × (n−1)! for n=1 gives 1! = 1 × 0! = 1, so 0! must equal 1. (2) There is exactly one way to arrange 0 elements (the empty arrangement). (3) Many formulas in combinatorics, such as the binomial coefficient, only produce sensible values with 0! = 1.

The factorial is central to combinatorics: the number of ways to arrange n distinct elements (permutations) is n!. For example, 3 books can be arranged on a shelf in 3! = 6 different ways. The binomial coefficient (n choose k) = n! / (k! × (n−k)!) counts how many k-element subsets an n-element set has. This is fundamental to probability theory and statistics.

JavaScript and most programming languages use 64-bit floating-point numbers (IEEE 754 double). The largest representable value is about 1.8 × 10³⁰⁸. 170! ≈ 7.26 × 10³⁰² is still below that, and 171! ≈ 1.24 × 10³⁰⁵ is also still representable. But 171! × 172 ≈ 2.14 × 10³⁰⁸ then exceeds Infinity. Our calculator limits the input to 170 to guarantee exact results.

For very large n, the Stirling approximation gives a good estimate: n! ≈ √(2πn) × (n/e)ⁿ. For n=10: 10! = 3,628,800, Stirling gives about 3,598,696 (error ≈ 0.8%). The approximation becomes more accurate as n grows. It is important in thermodynamics (entropy), information theory and for asymptotic analysis in algorithm design.

For business

Calculators for your website or app

Integrate our GDPR-compliant calculators as a widget or use our API. Perfect for HR portals, career pages and financial applications.

  • 100% GDPR-compliant - no cookies, no data storage
  • White-label - your branding, your colors
  • REST API for your own applications
  • Built by HEADON.pro - your digital agency
Learn more about HEADON.pro →

Request without obligation

Receive an individual quote from HEADON.pro

Your data will only be used to get in touch with you.
Privacy