Toolify

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.

n!
3628800
P(n, k) = n! / (n−k)! (permutations)
720
C(n, k) = n! / (k!(n−k)!) (combinations)
120

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: