permutations

permutations(n)

permutations(n, k)

Try it yourself:


permutations(): count ordered selections

permutations(n, k) counts ways to choose and arrange k distinct items from n. Order matters: choosing A then B differs from B then A.

Formula

The count is n!/(n-k)!. For example, choosing first and second place from five entrants produces permutations(5, 2) = 20.

Compare counting methods

Use combinations() when order does not matter, and combinationsWithRep() when repeats are allowed. factorial() supplies the underlying formula, while catalan() counts a different family of structures.

Input limits

n and k should be non-negative integers with k no greater than n. Counts grow quickly, so keep exact results when possible.

Try Permutations in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions