CALCZERO.COM

Permutation & Combination Calculator

Calculate permutations (nPr) when order matters and combinations (nCr) when order doesn't matter. Solve counting problems, find factorials, and understand the difference between arrangements and selections.

P(n, r) = n!/(n-r)!   |   C(n, r) = n!/(r!(n-r)!)
Total number of items to choose from (0-170)
Number of items to select/arrange (r ≤ n)
e.g., 10 digits, 26 letters
e.g., 4-digit PIN, 8-character password
Options

Results

Common Factorials Reference

n n! Scientific

How to Use This Calculator

Pick a calculation mode from the tabs at the top. Here's what each one does:

  • Both: Shows permutations and combinations side by side, which is great for comparing them
  • Permutations: Just nPr calculations
  • Combinations: Just nCr calculations
  • Factorial: Computes n! directly
  • Advanced: Handles special cases like repetition, circular arrangements, and multisets

Enter your total items as n and how many you're selecting as r. The calculator won't let r exceed n (you can't pick more items than you have). If you're working with really large numbers, you'll get a warning about precision limits.

For trickier problems, the Advanced tab has you covered. Need to count 4-digit PINs where digits can repeat? Use permutations with repetition for that. Arranging letters in MISSISSIPPI? You'd use multiset permutations. Seating people around a circular table? Circular permutations. Turn on step-by-step to see exactly how each calculation works. It's helpful for learning or double-checking homework.

What Are Permutations?

A permutation is an ordered arrangement where sequence matters. If you're shelving three books A, B, and C, then ABC and BAC are different arrangements. The books end up in different positions. P(n,r), also written nPr, tells you how many ways you can pick r items from n when order matters.

P(n, r) = n! / (n-r)!

Here's why the formula works: for your first pick, you've got n options. Once that's chosen, you have n-1 left for the second pick. Keep going until you've filled all r spots. That gives you n × (n-1) × (n-2) × ... × (n-r+1) total arrangements. This product is exactly n!/(n-r)! because dividing cancels out everything from (n-r) down to 1. Make sense?

Say you're picking a president, VP, and treasurer from 10 candidates. Order matters here because the roles are different. You've got 10 options for president, then 9 remaining for VP, then 8 for treasurer. So P(10,3) = 10 × 9 × 8 = 720 ways to fill these positions.

The key insight: each "slot" you fill reduces your options by one.

What Are Combinations?

A combination is an unordered selection where only membership matters, not arrangement. When you're picking 3 people from 10 for a committee where everyone has equal status, {A,B,C} is the same as {C,B,A}. They're the same committee. C(n,r), sometimes written nCr or "n choose r", is the count when order doesn't matter. Why divide by r! in the formula? Because each combination shows up as r! different permutations. Pick items A, B, and C—you can arrange them in 3! = 6 orders (ABC, ACB, BAC, BCA, CAB, CBA), but they're all the same combination. Dividing P(n,r) by r! counts each unique selection exactly once.

C(n, r) = n! / (r!(n-r)!)

Lotteries are the go-to example. When 6 numbers are drawn from 49, the order they come out doesn't affect whether you win. Drawing 1-2-3-4-5-6 wins the same as 6-5-4-3-2-1. That gives C(49,6) = 13,983,816 possible outcomes. Good luck beating those odds.

Permutations vs Combinations

Here's the test: does rearranging your selection create a different outcome? If yes, use permutations. If no, use combinations.

That's basically it.

Use permutations when positions are distinct or when ranking matters. Race results care about 1st, 2nd, and 3rd place specifically. Passwords treat "abc" and "cab" as completely different strings. Phone numbers, seating assignments, tournament brackets—all permutations because where each item ends up matters.

Use combinations when you're selecting a group with equal standing. Pizza toppings, lottery numbers, team members when everyone plays the same role—these are combinations. Poker hands are combinations because you can shuffle your cards around without changing what you're holding.

P(n, r) = C(n, r) × r!

Notice that permutations always outnumber combinations by exactly r!. Each combination can be rearranged in r! different orders. For P(10,3) = 720 and C(10,3) = 120, the ratio is 720/120 = 6 = 3!. Each of those 120 combinations corresponds to exactly 6 permutations.

Understanding Factorials

The factorial of n, written n!, is just the product of all positive integers from 1 to n. It tells you how many ways you can arrange n distinct items in a line. Five books can go on a shelf in 5! = 5 × 4 × 3 × 2 × 1 = 120 different orders: 5 choices for the first slot, 4 for the second, and so on.

Two special cases to remember: 0! = 1 and 1! = 1. 0! = 1 isn't random—it's necessary for formulas to work. C(n,0) = n!/(0! × n!) should equal 1 (there's exactly one way to choose nothing), and that only works if 0! = 1.

Factorials grow fast. Ridiculously fast.

While 10! is about 3.6 million, 20! exceeds 2 quintillion. By 70!, you've got over 100 digits. JavaScript can only handle factorials up to 170! before overflowing. That rapid growth is why even medium-sized n values give you huge numbers.

The Fundamental Counting Principle

If you can do one thing m ways and another thing n ways, you can do both together in m × n ways. All the permutation and combination formulas build on this multiplication idea.

Take a password with 3 lowercase letters followed by 2 digits. Each letter slot has 26 options, each digit slot has 10. With that fixed order, you get 26 × 26 × 26 × 10 × 10 = 1,757,600 possibilities. If you could mix letters and digits freely across all five positions, the calculation gets more complex—that's how problem structure shapes which counting method you use. Tree diagrams help visualize this. For a 3-digit PIN using 0-9, the tree has 10 branches at the first level, each splitting into 10 more, then 10 more again. Count the paths from root to leaves: 10 × 10 × 10 = 1000, which matches 10³.

Pascal's Triangle

Pascal's Triangle is a triangular array where each number equals the sum of the two numbers directly above it. Row n lists C(n,0) through C(n,n), which means you can look up combinations without calculating factorials. The triangle starts with 1 at the top, and every row begins and ends with 1.

You can spot several patterns quickly. It's symmetric: C(n,r) = C(n,n-r), so each row reads the same forwards and backwards. Every row adds up to 2ⁿ, which tells you the total number of subsets of an n-element set. There's also a diagonal sum pattern called the hockey stick identity—which has a fun name but we won't get into it here.

Pascal's Triangle also connects to the binomial theorem. When you expand (a+b)ⁿ, the coefficients are exactly the entries in row n. So (a+b)³ = a³ + 3a²b + 3ab² + b³ uses coefficients 1, 3, 3, 1 from row 3. That link between algebra and counting is why this triangle comes up a lot in math.

Permutations with Repetition

What happens when items can be reused? The counting changes completely.

A 4-digit PIN using digits 0-9 allows repetition. 1111 is valid, so is 1234. Each of the 4 positions has 10 choices independently, giving 10⁴ = 10,000 possible PINs. nʳ works whenever you're making r selections from n options with replacement allowed.

Permutations with Repetition = nʳ

Compare that to standard permutations. Without repetition, a 4-digit PIN using each digit at most once would be P(10,4) = 5,040. With repetition, you get 10,000—nearly double. For passwords the gap is even bigger: an 8-character lowercase password allows 26⁸ ≈ 208 billion combinations with repetition versus P(26,8) ≈ 62 billion without.

License plates, phone numbers, and DNA sequences all involve repetition. A plate with 3 letters then 4 digits has 26³ × 10⁴ = 175,760,000 possibilities. Each letter slot has all 26 options regardless of what came before, and each digit slot has all 10.

Permutations of Multisets

When you're arranging items and some are identical, you need multiset permutations. MISSISSIPPI has 11 letters, but it's not 11! arrangements—swapping two I's doesn't create a new word. With 4 I's, 4 S's, 2 P's, and 1 M, we have to account for those duplicates. You divide n! by the factorial of each group's size because shuffling identical items within a group doesn't produce a new arrangement. For MISSISSIPPI: 11!/(4! × 4! × 2! × 1!) = 39,916,800/(24 × 24 × 2 × 1) = 34,650 distinct arrangements. Without this correction, you'd way overcount.

Multiset Permutations = n! / (n₁! × n₂! × ... × nₖ!)

Same idea works for arranging colored balls in a row, books by the same author, or beads on a string. You just need to figure out which items are interchangeable, then group them correctly.

Circular Permutations

Circles are different from lines because rotations count as the same arrangement. Seating 5 people at a round table looks like it should be 5! arrangements, but if everyone moves one seat clockwise, you've got the same relative positioning. Since any of the n positions could be "first" in a linear view, circular permutations only count (n-1)! distinct arrangements.

Circular Permutations = (n-1)!

Think of it this way: fix one person's position to break the rotational symmetry. With that anchor in place, you can arrange the remaining n-1 people in (n-1)! ways around them. For 5 people at a round table, that's 4! = 24 distinct seatings, versus 120 if they were in a line.

Bracelets and necklaces add another twist: flipping the circle over creates yet another identical arrangement. For those, divide by 2 to get (n-1)!/2. A bracelet with 5 different beads has 4!/2 = 12 distinct designs, accounting for both rotations and reflections.

Derangements

A derangement is a permutation where no element stays in its original position. If 5 people toss their hats in a pile and each grabs one randomly, a derangement happens when nobody gets their own hat back.

The math gets tricky here, but stick with me.

D(n) = n! × (1 - 1/1! + 1/2! - 1/3! + ... + (-1)ⁿ/n!)

You get this formula through inclusion-exclusion. For small values: D(1) = 0 (one item has to stay put), D(2) = 1 (just swap them), D(3) = 2, D(4) = 9, D(5) = 44. As n gets larger, the ratio D(n)/n! approaches 1/e ≈ 0.368—roughly 36.8% of all permutations are derangements, no matter how big n is.

Classic examples: the "hat check problem" and "secret Santa." If each person draws a name and redraws if they get themselves, the number of valid assignments is D(n). The probability that someone gets their own name is about 1 - 1/e ≈ 63.2%, which is higher than most people expect.

Combinations with Repetition

What if you can pick the same item more than once, but order still doesn't matter? You need combinations with repetition. Picking 3 scoops from 5 ice cream flavors lets you repeat (chocolate, chocolate, vanilla) and doesn't care about order. Three scoops are three scoops. That's different from standard combinations where each item can only be picked once.

Combinations with Repetition = C(n+r-1, r)

There's a technique called "stars and bars" that makes this easier. Represent your r selections as stars and use n-1 bars to separate n categories. For 3 scoops from 5 flavors, arrange 3 stars and 4 bars. The pattern **|*|| means 2 of flavor 1, 1 of flavor 2, and none of the others. Counting all arrangements of these 7 symbols—choosing 3 positions for stars—gives C(7,3) = 35.

Works the same way for distributing identical items into distinct groups. How many ways can 10 identical cookies go to 4 kids? With n=4 and r=10: C(4+10-1, 10) = C(13,10) = 286 distributions.

Real-World Applications

Lotteries run entirely on combinations. Powerball asks you to match 5 numbers from 69 (order doesn't matter) plus 1 from 26. That's C(69,5) × 26 = 292,201,338 to 1 odds. A simpler 6/49 lottery has C(49,6) = 13,983,816 combinations, so jackpots roll over constantly. No "system" can change these odds.

The odds aren't in your favor.

Password security is all about permutations with repetition. An 8-character password using lowercase, uppercase, and digits has 62⁸ ≈ 218 trillion possibilities. Add special characters (95 total options) and you get 95⁸ ≈ 6.6 quadrillion. Each extra character multiplies your options by 62 or 95, which is why adding characters makes passwords so much stronger.

Sports use both. An NCAA bracket with 64 teams has 2⁶³ ≈ 9.2 quintillion possible outcomes. Fantasy lineup selection from a player pool uses combinations when everyone plays the same role, or permutations when positions differ.

Connection to Probability

Probability calculations depend on combinatorics when outcomes are equally likely. The formula P(event) = favorable outcomes / total outcomes needs accurate counting on both sides. Drawing 5 cards from a deck, the chance of getting all hearts is C(13,5) / C(52,5) = 1287 / 2,598,960 ≈ 0.0495%.

The birthday problem shows some unexpected results. In a group of just 23 people, there's better than 50% chance that two share a birthday. You calculate it with permutations: P(all different) = P(365,23) / 365²³. With 50 people, the odds of a shared birthday jump above 97%, way higher than most people guess.

Poker odds come down to counting combinations. A royal flush (10-J-Q-K-A of one suit) can happen in C(4,1) = 4 ways out of C(52,5) = 2,598,960 possible hands. That's about 0.000154%. A full house needs C(13,1) × C(4,3) × C(12,1) × C(4,2) = 3,744 ways, roughly 0.144%.

Common Mistakes to Avoid

  • Mixing up permutations and combinations: Before calculating, ask yourself: "Is ABC different from CBA?" If a lottery draws numbers one at a time but only the final set matters for winning, that's still a combination—what matters is the context, not how the problem is worded.
  • Forgetting that 0! = 1: Both P(n,0) = 1 and C(n,0) = 1 rely on this. There's exactly one way to arrange zero items (do nothing) and one way to select zero items (select none). The formulas only give correct answers when 0! = 1.
  • Computing full factorials before dividing: For P(100,3), just calculate 100 × 99 × 98 directly. Don't try to compute 100!/97! with huge intermediate values. Use symmetry too: C(100,97) = C(100,3), so pick the smaller r.
  • Assuming repetition is or isn't allowed: A "4-digit code with distinct digits" gives P(10,4) = 5,040. A "4-digit code" allowing repetition gives 10⁴ = 10,000. Always check whether replacement is permitted before picking a formula.