!

Factorial Calculator

Compute n! with exact BigInt precision — plus permutations, combinations & Stirling's approximation

What is a Factorial Calculator?

A factorial calculator computes the value of n! (n factorial) — the product of every positive integer from 1 up to n. This tool goes far beyond a simple multiplication: it uses JavaScript's native BigInt arithmetic to return exact integer results for every n from 0 to 170, displays the full digit count, converts the answer to scientific notation, shows a step-by-step expansion, and offers advanced features including permutations P(n,r), combinations C(n,r), a scrollable factorial table, and Stirling's approximation with percentage error.

Whether you are a student working through a Class 11 combinatorics problem, preparing for JEE, studying probability theory, or simply curious about how astronomically large 100! is (it has 158 digits), this calculator handles every case instantly in your browser with no server calls and no data stored.

Factorial Formula & Examples

The factorial of a non-negative integer n is defined recursively and iteratively:

n! = n × (n−1) × (n−2) × … × 2 × 1
0! = 1   (by definition — the empty product)
1! = 1
5! = 5 × 4 × 3 × 2 × 1 = 120
10! = 3,628,800

The factorial function grows faster than any polynomial or exponential function. 20! already exceeds 2.4 × 1018, while 100! ≈ 9.33 × 10157 — a number with 158 digits that dwarfs the number of atoms in the observable universe (estimated at around 1080).

Factorials in Permutations & Combinations

The two most fundamental counting techniques in combinatorics are both expressed using factorials:

P(n, r) = n! / (n − r)!     [ordered arrangements]
C(n, r) = n! / (r! × (n − r)!)   [unordered selections]

Permutations count the number of ways to arrange r items chosen from n distinct items where order matters. For example, the number of ways to award gold, silver, and bronze medals from 10 athletes is P(10, 3) = 10! / 7! = 720.

Combinations count selections where order does not matter. Choosing a 3-person committee from 10 candidates gives C(10, 3) = 10! / (3! × 7!) = 120 possible committees.

Factorial Table: 0! to 20!

nn!DigitsScientific
0111.00 × 100
1111.00 × 100
2212.00 × 100
3616.00 × 100
42422.40 × 101
512031.20 × 102
672037.20 × 102
75,04045.04 × 103
840,32054.03 × 104
9362,88063.63 × 105
103,628,80073.63 × 106
1139,916,80083.99 × 107
12479,001,60094.79 × 108
136,227,020,800106.23 × 109
1487,178,291,200118.72 × 1010
151,307,674,368,000131.31 × 1012
1620,922,789,888,000142.09 × 1013
17355,687,428,096,000153.56 × 1014
186,402,373,705,728,000166.40 × 1015
19121,645,100,408,832,000181.22 × 1017
202,432,902,008,176,640,000192.43 × 1018

Worked Examples

5! = 120
5 × 4 × 3 × 2 × 1
Ways to arrange 5 books on a shelf
10! = 3,628,800
10 × 9 × … × 1
Permutations of 10 distinct items
0! = 1
Empty product = 1
Defined — not derived — by convention

Real-World Uses of Factorials

  • Card shuffling: A standard deck of 52 cards has 52! ≈ 8.07 × 1067 possible orderings. Every time you shuffle a deck, you almost certainly create a unique arrangement that has never existed before in human history.
  • Probability: Computing the probability that n events occur in a specific order requires dividing by n! to remove the effect of ordering.
  • JEE and CBSE: Class 11 and 12 boards dedicate an entire chapter to permutations and combinations. Factorial notation is used in nearly every problem in that chapter.
  • Password and PIN combinations: Calculating how many distinct 4-digit PINs can be formed from 10 digits without repetition is P(10, 4) = 5,040.
  • Statistical physics: The Boltzmann entropy formula uses factorials via Stirling's approximation when counting microstates of a system.
  • Binomial theorem: The coefficients in (a + b)n are combinations C(n, k) — each defined using three factorials.

Frequently Asked Questions

What is a factorial?
A factorial of a non-negative integer n (written n!) is the product of all positive integers from 1 up to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. Factorials grow at a superexponential rate and are foundational in combinatorics, probability, algebra, and mathematical analysis.
What is 0! (zero factorial)?
By mathematical convention, 0! = 1. This may seem surprising, but it is defined — not derived — so that formulas for permutations and combinations remain consistent. When you choose 0 items from n items, there is exactly 1 way to do it (choose nothing). The "empty product" of no numbers also equals 1.
What is the largest factorial a computer can calculate?
This calculator uses JavaScript's BigInt to return exact integer results for all n from 0 to 170. The value 170! has 307 digits. For n > 170, the floating-point representation overflows to Infinity, so an approximation via Stirling's formula is shown instead. Specialist arbitrary-precision libraries (Python's math.factorial, for example) can compute factorials of millions.
How are factorials used in permutations and combinations?
Permutations P(n, r) = n! / (n−r)! counts the number of ordered ways to choose r items from n. Combinations C(n, r) = n! / (r! × (n−r)!) counts unordered selections. Both formulas reduce n!, (n−r)!, and r! — so accurate factorial arithmetic is the core of all counting problems.
What is n! used for in JEE and CBSE maths?
Factorials are central to the Permutations & Combinations chapter in CBSE Class 11 and appear repeatedly in JEE Main and Advanced. Common question types include: arranging letters of a word (including repeated letters), forming numbers from given digits, selecting committees, distributing objects into groups, and computing binomial coefficients for the Binomial Theorem chapter.
What is Stirling's approximation?
Stirling's approximation states that n! ≈ √(2πn) × (n/e)^n. For n = 10 the error is about 0.83%; for n = 100 it drops below 0.08%. The approximation becomes increasingly accurate as n grows. It is widely used in statistical physics (entropy calculations), information theory, and asymptotic analysis of algorithms where exact factorials are impractical.
Can factorials be calculated for negative numbers or fractions?
The standard factorial is only defined for non-negative integers. However, mathematicians extend it using the Gamma function: Γ(n+1) = n! for positive integers, and Γ is defined for all real and complex numbers except non-positive integers. For example, (1/2)! = Γ(3/2) = √π/2 ≈ 0.8862. This calculator covers non-negative integers 0 to 170 only.
Is my data stored on this site?
No. All calculations run entirely in your browser using JavaScript. No input values are ever transmitted to any server. Calculator Junction does not store, log, or share any user data.