Math

Factorial, Combinations, and Permutations

Calculator Free · Private
Reviewed by: (política editorial ) · Last reviewed:
Was this calculator helpful?

The factorial of a non-negative integer n, written n!, is the product of all positive integers from 1 to n. Factorials, permutations, and combinations are foundational topics in US AP Statistics, college discrete math, and the AMS standard combinatorics curriculum. This calculator handles n!, P(n, r) (order matters) and C(n, r) (order doesn't matter), uses native BigInt so 100! (≈ 9.3 × 10¹⁵⁷) computes exactly, and is useful for Powerball/Mega Millions probability, poker hands, and password entropy.

Last reviewed: May 19, 2026 Verified by Source: NIST Digital Library of Mathematical Functions — Factorials and Combinatorial Identities, Wolfram MathWorld — Factorial, American Mathematical Society — Combinatorics Resources, Khan Academy — Permutations and Combinations, MDN - BigInt (JavaScript) 100% private

When to use this calculator

  • You're calculating the probability of winning the lottery: C(n, r).
  • You want to know how many poker hands exist in a 52-card deck: C(52,5).
  • You're working on combinatorics problems in high school or college.
  • You're analyzing how many possible orderings a password or array has.
  • You're computing binomial coefficients for a binomial distribution in statistics.

Example: How many 5-card hands can be formed from a 52-card deck?

  1. Context: we pick 5 cards out of 52, order doesn't matter (3♠ 4♠ 5♠ 6♠ 7♠ is the same hand as 7♠ 6♠ 5♠ 4♠ 3♠).
  2. Use combinations: C(52, 5) = 52! / (5! × 47!).
  3. Simplification: (52 × 51 × 50 × 49 × 48) / (5 × 4 × 3 × 2 × 1).
  4. Numerator: 52 × 51 × 50 × 49 × 48 = 311,875,200.
  5. Denominator: 5! = 120.
  6. Result: 311,875,200 / 120 = 2,598,960.
Result: There are C(52, 5) = 2,598,960 distinct 5-card poker hands in a standard US 52-card deck. The probability of drawing any one specific hand is 1 / 2,598,960 ≈ 0.0000385% (per NIST/SEMATECH combinatorics conventions).

How it works

3 min read

Factorial (n!)

n! = n × (n−1) × (n−2) × ... × 2 × 1
0! = 1 (by convention)
1! = 1

Examples:

  • 5! = 5 × 4 × 3 × 2 × 1 = 120

  • 10! = 3,628,800

  • 20! = 2,432,902,008,176,640,000

  • 70! ≈ 1.2 × 10¹⁰⁰ (roughly a googol)

  • 100! ≈ 9.3 × 10¹⁵⁷
  • What It Means

    Factorial counts the ways to arrange n distinct objects. If you have 5 different books on a shelf, there are 120 different ways to order them.

    Permutations — P(n, r)

    P(n, r) = n! / (n − r)!
            = n × (n−1) × (n−2) × ... × (n−r+1)

    Ways to order r elements taken from n, where order matters.

    Classic Example

    How many ways to assign gold, silver, and bronze in a race of 10 runners?

    P(10, 3) = 10! / 7! = 10 × 9 × 8 = 720

    Order matters because Runner A in gold and Runner B in silver is different from Runner B in gold and Runner A in silver.

    Combinations — C(n, r)

    C(n, r) = n! / (r! × (n−r)!)

    Ways to pick r elements out of n, regardless of order. Read as 'n choose r.' Also written ⁿCᵣ or as the binomial coefficient (n r).

    Classic Example

    How many 5-card hands exist in a 52-card deck?

    C(52, 5) = 52! / (5! × 47!) = 2,598,960

    Order doesn't matter because the hand is the set of cards, not their sequence.

    Key Difference: Permutation vs. Combination

    PermutationCombination
    OrderMattersDoesn't matter
    Formulan! / (n−r)!n! / (r! × (n−r)!)
    ExampleRace podiumCard hand
    RelationshipP = C × r!C = P / r!
    AlwaysP(n,r) ≥ C(n,r)

    Mnemonic

  • If you can distinguish order (1st, 2nd, 3rd), it's a permutation.

  • If only which elements you picked matters, it's a combination.
  • Real-World Applications

    Lottery Probability

    Powerball-style (5 of 69 + 1 of 26): massively low odds.

    Poker

    HandCombinationsProbability
    Royal flush40.000154%
    Straight flush360.00139%
    Four of a kind6240.024%
    Full house3,7440.144%
    Flush5,1080.197%
    Any hand2,598,960100%

    Combinatorics in Statistics

    Binomial distribution: probability of getting k successes in n tries (flipping n coins).

    P(X = k) = C(n, k) × p^k × (1−p)^(n−k)

    Where p is the probability of success in one trial.

    Algorithms and Big O

  • Traveling Salesman Problem (TSP): n! possible routes — explodes for n > 10.

  • Sorting: there are n! possible orderings of n elements.

  • Sudoku: ≈ 6.67 × 10²¹ valid boards.

  • Chess: more than 10⁴³ legal positions (Shannon's estimate).
  • Large Factorials

    Factorials grow so fast they lose intuitive scale:

    nn!
    5120
    10≈ 3.6 × 10⁶
    15≈ 1.3 × 10¹²
    20≈ 2.4 × 10¹⁸
    30≈ 2.7 × 10³²
    50≈ 3.0 × 10⁶⁴
    70≈ 1.2 × 10¹⁰⁰ (a googol)
    100≈ 9.3 × 10¹⁵⁷
    170≈ 7.3 × 10³⁰⁶ (JavaScript Number limit)

    Beyond that, BigInt is needed (arbitrarily large integers). This calculator uses BigInt for n up to 1000.

    Gamma Function — extended factorial

    The gamma function Γ(n+1) = n! extends factorial to real and complex numbers (except 0, −1, −2, …). Example: Γ(0.5) = √π. Used in advanced statistics (gamma, chi-squared, Student's t distributions).

    Stirling's Approximation

    For very large n, factorial is approximated with:

    n! ≈ √(2πn) × (n/e)^n

    Excellent approximation starting from n = 10. Useful in asymptotic analysis.

    Common Mistakes

    1. Computing 0!: many say 0. It's 1 by convention (so formulas keep working).
    2. Confusing P(n,r) with C(n,r): ask whether order matters.
    3. Brute-forcing C(52,5): don't compute 52!/47!/5!. Simplify: (52×51×50×49×48)/(5×4×3×2×1).
    4. Permutations with repetition: if elements repeat (like letters in 'MISSISSIPPI'), the formula changes: n! / (n₁! × n₂! × ...).
    5. Trying n! with JavaScript Number: overflow beyond n = 170. Use BigInt.

    Frequently asked questions

    Why is 0! = 1?

    By mathematical convention that keeps formulas consistent. C(n, 0) must be 1 (there's only one way to 'choose nothing'). For C(n,0) = n!/(0!×n!) to equal 1, 0! must be 1. It also fits the gamma function: Γ(1) = 1, and Γ(n+1) = n!. Think of 0! as an empty product = 1 (analogous to empty sum = 0).

    What about factorial of negative numbers?

    Undefined for negative integers (division by zero in the gamma extension). But the gamma function Γ(n+1) extends factorial to reals and complexes, except at negative integers 0, −1, −2, … where there are poles. Γ(0.5) = √π ≈ 1.77, Γ(1.5) = 0.5 × √π ≈ 0.89.

    When do I use permutations vs. combinations?

    If order matters (podium, passwords, numbered seats), use permutations P(n,r). If order doesn't matter (card hands, teams, groups), use combinations C(n,r). Quick rule: ask 'does the result change if I change the order?' If yes, permutation. If no, combination.

    How do I calculate my Powerball odds?

    Powerball: pick 5 of 69 white balls + 1 of 26 red. Combinations: C(69,5) × 26 = 292,201,338. Probability of jackpot: 1 / 292,201,338 ≈ 0.00000034%. You're more likely to be struck by lightning than win.

    What is a binomial coefficient?

    Another name for combinations. C(n, r) is also written (n r) ('n choose r') or ⁿCᵣ. It appears in the binomial theorem: (a + b)ⁿ = Σ C(n, k) × aⁿ⁻ᵏ × bᵏ. It forms Pascal's triangle, where each number is the sum of the two above.

    What is Pascal's triangle?

    Triangular arrangement where each row n contains the binomial coefficients C(n,0), C(n,1), …, C(n,n). Each number is the sum of the two directly above. Row 0: 1. Row 1: 1 1. Row 2: 1 2 1. Row 3: 1 3 3 1. Row 4: 1 4 6 4 1. These numbers appear in the binomial theorem and combinatorics.

    How do I handle huge factorials without losing precision?

    Use BigInt (JavaScript: BigInt(n) instead of Number(n)). Number loses precision beyond 2^53 ≈ 9 × 10¹⁵. To compute 50! or 100!, you need BigInt. This calculator uses BigInt so you get exact factorials with hundreds of digits. For fast approximations, use Stirling's formula: n! ≈ √(2πn) × (n/e)^n.

    What if I have repeated elements?

    They're permutations with repetition. If you have n total elements with n₁ of type A, n₂ of type B, etc., distinct permutations are n! / (n₁! × n₂! × … × nₖ!). Example: word 'PAPA' has 4 letters (2 P, 2 A), distinct permutations: 4! / (2! × 2!) = 24/4 = 6. Valid for 'AAPP', 'APAP', 'APPA', 'PAAP', 'PAPA', 'PPAA'.

    How many distinct passwords exist?

    Depends on alphabet and length. 8-character password with lowercase letters (26 options): 26^8 = 208,827,064,576 (~209 billion). Adding uppercase (52): 52^8 ≈ 5.35 × 10¹³. With digits (62): 62^8 ≈ 2.18 × 10¹⁴. With symbols (94): 94^8 ≈ 6.10 × 10¹⁵. That's why length matters more than complexity for password security.

    Sources and references