Permutations of a set are rearrangements of its elements. Order matters, so the permutation “abc” is considered different from “acb” even though they have the same letters. (For cases where order does not matter, see the next page.)

This page *constructs* (as opposed to merely counting) the permutations for (modestly-sized) sets. It is a well-known result that for an N-element set, there are N! (N factorial) permutations.

However, this fact does not tell you what those permutations are. In the next section you can list these permutations. The elements in the list will always be words formed with the letters a, b, c, etc.

Each bulleted line finds one or more permutations, explained below. To calculate, enter the required numbers in the round text fields, and click the in the same line.

- All of letters.
- The th of letters. (Zero-based.)
- (From N letters, permute k of them.)

Result

The first bulleted line above calculates

*all*the permutations on N letters. This can be a very large list and a very time-consuming calculation. So if you enter a large value for N (larger than 9) you will be quizzed on whether you really mean it or not.In fact, the calculation proceeds very quickly — it is the text-processing, the unpacking of the result and rendering it into the Web page, that is vastly slower. Web pages are not necessarily the most efficient way to perform calculations. However, they can be very illustrative. And should you choose to try your own hand at generating these lists (using e.g. C or Python or Ruby or Lisp) you will have at least some small values to compare to.

- The second line above calculates only a single permutation, which is of course a much faster calculation. This is called a generator function. If you need to run through all permutations and do something with each one, you may not want to pre-calculate them all first — that could take up a lot of space. Instead, just step through the permutations by calling the generator repeatedly.
- The third line finds a variation of the first: the source alphabet still has N letters but our permutations are only of length k, where 0 ≤ k ≤ N. (Called “N permute k” or “P(N,k)” in the literature.) This might seem like a simpler calculation — the list is always shorter than N!. But it is surprisingly tricky to do this in any kind of efficient way. I am using a process suggested by Alistair Israel. In fact, his algorithm is a generator, and I am just calling it sequentially to get the result.

The code I am using is all visible: just do a “View Page Source” or its equivalent on this Web page.

The next page will demonstrate similar calculations for the cases where order does not matter — that is, for combinations.

Previous ☜ Navigate through the Combinatorics pages ☞ Next