n!
✓ Editorially reviewed by Derek Giordano, Founder & Editor · BA Business Marketing

Factorial & Combinations Calculator

n! nPr nCr

Last reviewed: January 2026

🧮
500 calculators, no signup required
Finance · Health · Math · Science · Business
nnng.com

What Is a Factorial & Combinations Calculator?

Calculate factorials (n!), permutations (nPr), and combinations (nCr) for any positive integers. This calculator runs entirely in your browser — your data stays private, and no account is required.

Understanding Factorials

A factorial (n!) is the product of all positive integers from 1 to n: 5! = 5 × 4 × 3 × 2 × 1 = 120. Factorials grow astronomically fast — 20! already exceeds 2 quintillion, and 52! (the number of ways to shuffle a deck of cards) has 68 digits.[1] Factorials are foundational to combinatorics: the number of permutations of n items is n!, and combinations use factorials in the formula C(n,r) = n!/(r!(n-r)!).[2] By convention, 0! = 1, which is not arbitrary but necessary for combinatorial formulas to work correctly — there is exactly one way to arrange zero objects.[3] Use the Combination Calculator for counting problems that use factorials.

Real-World Applications

Lottery odds: choosing 6 numbers from 49 = C(49,6) = 13,983,816 combinations. Every combination is equally likely, so the odds of winning are 1 in ~14 million. Password security: an 8-character password using 94 printable ASCII characters has 94⁸ ≈ 6.1 × 10¹⁵ possibilities — very different from factorial calculation (ordering a set) because characters can repeat. Tournament brackets: C(64,2) = 2,016 possible first-round matchups in a 64-team bracket. The "birthday problem": the odds that 2 of 23 random people share a birthday are over 50% — proven using combinations and probability.

Factorial Values Reference

nn!DigitsUse Case
51203Small permutations
103,628,8007Combination problems
151,307,674,368,00013Card game odds
202.43 × 10¹⁸19Cryptography
528.07 × 10⁶⁷68Deck shuffling

Permutations vs. Combinations Explained

The distinction between permutations and combinations trips up students and professionals alike, yet it governs everything from password security to genetic analysis. A permutation counts arrangements where order matters: how many ways can you seat 5 people in 5 chairs? The answer is 5! = 120, because each position is distinct. A combination counts selections where order is irrelevant: how many 5-card poker hands can be dealt from 52 cards? That is C(52,5) = 2,598,960. The key question is always whether rearranging the same items produces a different outcome. If you are forming a committee, order does not matter — use combinations. If you are assigning ranked prizes, order matters — use permutations.

The permutation formula nPr = n!/(n−r)! gives the number of ordered arrangements of r items chosen from n. The combination formula nCr = n!/(r!(n−r)!) removes duplicate orderings by dividing by r!. For any given n and r, nPr is always greater than or equal to nCr because permutations distinguish between arrangements that combinations treat as identical. When r = n, nPn = n! (every item is placed) and nCn = 1 (there is only one way to choose all items regardless of order).

Factorial Notation in Statistics and Probability

Factorials underpin the binomial coefficient, which appears throughout statistics. The probability of getting exactly k successes in n independent trials with success probability p is C(n,k) × p^k × (1−p)^(n−k). This binomial distribution uses factorials three times within a single probability calculation. In hypothesis testing, permutation tests shuffle observed data to create a null distribution — the number of possible shuffles is n!, making exact computation feasible only for small samples. For larger datasets, statisticians use sampling or Stirling's approximation to estimate factorial-based quantities.

The multinomial coefficient extends combinations to multiple groups: n!/(k₁!k₂!...kₘ!) counts the ways to divide n items into m groups of specified sizes. Distributing 12 jurors into 3 deliberation rooms of 4 each uses the multinomial coefficient: 12!/(4!4!4!) = 34,650 possible assignments. This appears in natural language processing for word-frequency models and in genetics for allele distribution calculations.

Computational Limits and Big Numbers

Standard 64-bit floating-point numbers overflow at 170! (which has 307 digits), so computing exact factorials beyond this point requires arbitrary-precision arithmetic libraries. Programming languages like Python handle big integers natively, but JavaScript loses precision beyond 2⁵³. This calculator uses big-number techniques to display exact results for inputs well beyond what standard arithmetic supports. When exact values are unnecessary, Stirling's approximation (n! ≈ √(2πn)(n/e)ⁿ) provides logarithmic estimates that are accurate to within 1% for n > 10 and improve rapidly as n grows.

The gamma function Γ(n) = (n−1)! extends factorials to non-integer and even complex numbers. Γ(0.5) = √π ≈ 1.7725, meaning "half factorial" has a precise mathematical value. This extension is essential in advanced statistics (the chi-squared distribution uses gamma functions), physics (partition functions in thermodynamics), and engineering (signal processing). While this calculator handles integer factorials, understanding the gamma function connection reveals why factorials appear in so many scientific formulas — they are a special case of a much broader mathematical structure.

Factorials in Computer Science

Algorithm complexity analysis frequently involves factorials. The traveling salesman problem — finding the shortest route visiting n cities exactly once — has n!/2 possible routes when the starting city is fixed. For 20 cities, this is over 60 quadrillion routes, making brute-force solutions computationally impossible. This is why the problem is classified as NP-hard: no known algorithm solves it efficiently for large n. Heuristic methods like nearest-neighbor, simulated annealing, and genetic algorithms find good (but not guaranteed optimal) solutions in reasonable time. Understanding that n! grows faster than any exponential function (2ⁿ, 3ⁿ, etc.) explains why factorial-complexity problems are considered intractable.

Hash functions and cryptographic protocols rely on factorial-sized spaces for security. The number of possible orderings of a 256-element set is 256!, a number with 507 digits — far larger than the number of atoms in the observable universe (approximately 10⁸⁰). This immense size makes certain brute-force attacks mathematically impossible within the lifetime of the universe. Factorial-based counting also appears in database query optimization (determining the most efficient join order for n tables requires evaluating n! orderings), compiler design (register allocation), and network routing (packet switching through n nodes).

Derangements and Subfactorials

A derangement is a permutation where no element appears in its original position. The number of derangements of n items, denoted !n or D(n), equals n! × Σ(−1)^k/k! for k from 0 to n. For large n, the probability of a random permutation being a derangement approaches 1/e ≈ 36.79%. The classic illustration is the "hat check" problem: if n people check their hats and the hats are returned randomly, the probability that nobody receives their own hat is approximately 1/e regardless of how many people are involved. This counterintuitive result — that the probability stabilizes almost immediately and does not approach 0 or 1 — is a fundamental result in combinatorics with applications in cryptography, genetics (random chromosome segregation), and card shuffling analysis.

Why is 0! equal to 1?
Two ways to see it. Arithmetic: n! = n × (n−1)!, so 1! = 1 × 0!, and 1! = 1, therefore 0! must equal 1. Combinatorially: C(n,0) — the number of ways to choose 0 items from n — equals 1 (there is exactly one way to choose nothing: choose nothing). C(n,0) = n! ÷ (0! × n!) = 1/0! = 1, which only works if 0! = 1. Both approaches lead to the same conclusion. It is a definition chosen to make the formulas work consistently.
Why does 0! equal 1?
This is a convention, but a deeply logical one. The factorial of n counts the number of ways to arrange n distinct objects. There is exactly one way to arrange zero objects: do nothing. Mathematically, the recursive definition n! = n × (n−1)! requires 0! = 1 for consistency — otherwise 1! = 1 × 0! would break. The convention also ensures that the combinations formula C(n,0) = n!/(0!·n!) = 1, confirming there is exactly one way to choose nothing from a set. Factorials grow extraordinarily fast: 20! = 2.4 quintillion, and 70! exceeds the estimated number of atoms in the observable universe. For related calculations, try our Combination Calculator and our Permutation Calculator.
How fast do factorials grow?
Incredibly fast — faster than exponential functions. 10! ≈ 3.6 million. 20! ≈ 2.4 quintillion. 100! has 158 digits. Stirling approximation (n! ≈ √(2πn)(n/e)ⁿ) estimates large factorials without computing the full product. This explosive growth is why brute-force approaches to combinatorial problems become computationally impossible even for moderate n values.
What is a double factorial?
A double factorial (n!!) multiplies every other integer down to 1 or 2. For odd n: n!! = n × (n-2) × (n-4) × ... × 3 × 1. For even n: n!! = n × (n-2) × ... × 4 × 2. So 7!! = 7 × 5 × 3 × 1 = 105 and 8!! = 8 × 6 × 4 × 2 = 384. Double factorials appear in physics (quantum mechanics) and statistics (moments of normal distributions).
Where are factorials used in real life?
Factorials appear in probability (lottery odds use combinations with factorials), statistics (permutation tests), computer science (algorithm complexity analysis), physics (quantum mechanics partition functions), and even card games — there are 52! ways to shuffle a deck, a number so large that no two truly random shuffles in history have likely produced the same ordering.

See also: Prime Number Checker · Exponent Calculator · GCD & LCM Calculator

How to Use This Calculator

  1. Enter a number for factorial — Input any non-negative integer. Factorial (n!) means multiplying every integer from 1 to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120.
  2. Review the factorial result — The calculator shows the full multiplication chain and final result. Factorials grow astronomically — 10! = 3.6 million, 20! = 2.4 quintillion.
  3. Calculate permutations or combinations — Enter n and r values to compute nPr (order matters) or nCr (order doesn't matter). The calculator shows the formula and step-by-step work.

Tips and Best Practices

Factorials grow faster than exponential functions. 10! = 3,628,800. 20! = 2.4 × 10¹⁸. 100! has 158 digits. A deck of 52 cards can be arranged in 52! ≈ 8 × 10⁶⁷ ways — more than the number of atoms in the observable universe.

0! = 1 by definition, not by intuition. This isn't a mistake — it's necessary for the combination formula to work. C(n,0) should equal 1 (there's one way to choose nothing), and the formula C(n,0) = n!/(0!×n!) requires 0! = 1 to produce the correct answer.

Use Stirling's approximation for very large factorials. n! ≈ √(2πn) × (n/e)ⁿ. This approximation is surprisingly accurate for n > 10 and is used in statistics, physics, and computer science when exact factorials would overflow calculators.

Factorials appear everywhere in probability. The number of ways to arrange n distinct items is n!. The number of ways to choose r items from n is n!/(r!(n-r)!). See our Combination Calculator, Permutation Calculator, and Probability Calculator for applied counting problems.

See also: Combination Calculator · Permutation Calculator · Probability Calculator · Scientific Calculator

📚 Sources & References
  1. [1] Wolfram MathWorld. Factorial. MathWorld
  2. [2] Khan Academy. Permutations and Factorials. KhanAcademy.org
  3. [3] NIST. Combinatorial Functions. NIST.gov
  4. [4] OpenStax. Counting Principles. OpenStax.org
Editorial Standards — Every calculator is built from peer-reviewed formulas and official data sources, editorially reviewed for accuracy, and updated regularly. Read our full methodology · About the author