Permutations
Permutations with repetition
Combinations
Combinations with repetition

    More information about permutations and combinations

    Permutation and combination calculator

    How many podiums can eight runners make, how many lottery tickets are there, and how many words can you spell with the letters of MISSISSIPPI? Every counting question comes down to two questions: does the order matter, and may an item be picked more than once? Enter n and k and see all four answers at once, exact to the last digit, with the formula worked out for your numbers, a picture of why it counts what it counts, and the actual arrangements written out one by one. Enter n, the number of items, and k, the number you pick, or choose a worked example. Two switches give the four ways to count: does the order matter, and may an item be picked more than once? All four results are shown at once; click one to see its formula with your numbers, and a picture of how the count comes about. The items (letters, words, numbers or emoji, separated by spaces or commas, or the letters of one word) set n, show how many ways there are to put all of them in a row, and the list writes out the actual results in alphabetical order. Repeated items count once per distinct result.

    How it works

    1. Enter n, the number of items, and k, the number you pick, or choose a worked example such as a lottery draw, a PIN or a poker hand.
    2. Switch Order matters and Repetition allowed, or click one of the four tiles, to see that case's formula with your numbers and a picture of the count.
    3. Type your own items, words, numbers, emoji or the letters of a word, to count their arrangements and list the actual results; copy them or download them as .txt or CSV.

    Two questions, four formulas

    If the order matters and nothing repeats, there are n choices for the first place, n − 1 for the second and so on: P(n, k) = n! / (n − k)!, so a podium of three from eight runners can be filled in 8 × 7 × 6 = 336 ways. If items may repeat, every place has all n choices: nᵏ, so a 4-digit PIN has 10⁴ = 10,000 possibilities. If the order does not matter, every selection of k items was counted k! times, once for each order: C(n, k) = n! / (k! (n − k)!), and a lottery of 6 from 49 has 13,983,816 tickets. And if items may repeat but the order does not matter, as with scoops of ice cream, the stars-and-bars trick gives C(n + k − 1, k).

    Repeated letters and exact big numbers

    When some items are the same, swapping them changes nothing, so you divide by the orders of each group of equal items. The 11 letters of MISSISSIPPI, with four I's, four S's and two P's, can be arranged in 11! / (4! · 4! · 2!) = 34,650 distinct ways. The list writes out such distinct results only once, in alphabetical order. The calculator works with whole numbers of any size, so C(1000, 500), a number of 300 digits, is exact to the last digit: it is shown with its number of digits and in scientific notation, and Copy gives you every digit.

    Frequently asked questions

    What is the difference between a permutation and a combination?

    In a permutation the order matters: gold, silver and bronze for Ann, Ben and Cara is a different result from Cara, Ben and Ann. In a combination only the selection counts: a lottery ticket with 3, 17 and 41 is the same ticket whatever order the balls were drawn in. Every combination of k items corresponds to k! permutations, so C(n, k) = P(n, k) / k!.

    Why is 0! equal to 1, and why is there one way to choose nothing?

    There is exactly one way to arrange no items at all: the empty arrangement. Defining 0! = 1 keeps the formulas working at the edges, so that C(n, 0) = C(n, n) = 1 and P(n, n) = n!. In the same way n⁰ = 1, including 0⁰ in counting: there is one list of length zero.

    When do I use combinations with repetition?

    When you choose k items from n kinds, each kind may be taken more than once, and the order does not matter: three scoops from five flavours, a handful of coins, or a dozen doughnuts from six sorts. Write each choice as k stars split into n groups by n − 1 bars; choosing which of the n + k − 1 places hold the stars gives C(n + k − 1, k), 35 for the scoops.

    How big can n and k be?

    Up to 1,000 each. The counts are computed with exact whole numbers, so even 1000! with its 2,568 digits is exact; long results are shown with their number of digits and in scientific notation, and Copy gives all the digits. The list writes out the first 1,000 results for k up to 24.

    How many combinations of 4 numbers from 0 to 9 are there?

    It depends on the kind. A 4-digit code where digits may repeat and order matters has 10⁴ = 10,000 possibilities; with no digit repeated, 10 × 9 × 8 × 7 = 5,040. If order does not matter, there are C(10, 4) = 210 sets of four different digits, or 715 when digits may repeat. n = 10 and k = 4 shows all four.

    Ready to try it?

    Open PictorX in your browser — no install, no credit card required to start.

    Go to Editor