Factorial / Permutations / Combinations Calculator
Enter n and k. Returns n!, P(n,k) (ordered selections), and C(n,k) (unordered selections). Useful for probability, statistics, and combinatorics homework.
How it works
Factorial
n! (read 'n factorial') is the product of all positive integers from 1 to n. So 5! = 1ร2ร3ร4ร5 = 120. By convention, 0! = 1 (the empty product).
Factorials grow extremely fast. 10! = 3.6M, 20! = 2.4ร10ยนโธ, 100! has 158 digits. Floating-point breaks at 21! (because of double-precision limit); we use BigInt for exact values up to n=5000.
Permutations vs combinations
Permutations P(n,k) = n! / (nโk)!: number of ordered ways to choose k items from n. P(5,2) = 20: pick first place from 5, second from remaining 4 = 5ร4 = 20.
Combinations C(n,k) = n! / (k!(nโk)!): number of unordered ways. C(5,2) = 10: same picks but {first, second} = {second, first} so divide by 2!. The famous 'n choose k'.
Use permutations when order matters (race podium, password order). Use combinations when only the chosen set matters (lottery numbers, committee selection). C(n,k) โค P(n,k) always; equal when k=1.
Where these come up
Probability: dice, cards, coin flips. P(3 heads in 5 flips) = C(5,3) ร (1/2)โต = 10/32. Combinations let you count favorable outcomes.
Statistics: binomial distribution uses C(n,k). Sampling without replacement uses combinations.
Computer science: counting subsets, complexity analysis (e.g., k-clique enumeration is C(n,k)), graph algorithms.
Real-world: lottery odds (US Powerball: C(69,5) ร 26 โ 292M combinations). Restaurant menu combos: 'pick 3 sides from 8' is C(8,3) = 56 ways.
Frequently asked questions
โบWhy is 0! = 1?
By convention, the 'empty product' is 1 (just like the empty sum is 0). It also makes formulas like C(n,0) = 1 (one way to choose nothing) work consistently.
โบWhat's the largest factorial this can compute?
n=5000 gives a 16,326-digit number. We cap at 5000 to prevent the browser from freezing on huge inputs. For larger, use a CAS.
โบWhat's the difference between permutations and combinations?
Order matters in permutations, doesn't in combinations. {A,B} is the same combination as {B,A} but two different permutations: AB and BA.
โบAre factorials defined for negative numbers?
Not in the standard sense. The gamma function ฮ(x) extends factorial to all real numbers (and complex), but our calculator handles only non-negative integers.
โบWhat's the formula for combinations?
C(n,k) = n! / (k! ร (n-k)!). Read as 'n choose k'. Equivalently: P(n,k) / k! since order doesn't matter.
โบHow accurate is this?
Exact for all values within range. We use BigInt arithmetic, which has no floating-point error.
โบWhy is 70! so much bigger than 60!?
Each factorial multiplies by the next integer. 70! is roughly 60! ร 61 ร 62 ร โฆ ร 70 โ 60! ร 1.4 ร 10ยนโท. Factorials grow faster than exponential โ they're roughly n^n ร e^-n ร โ(2ฯn) by Stirling's approximation.
โบDoes the data leave my browser?
No. Calculation runs locally; nothing is sent to a server.
Related tools
Last updated: