Skip to main content

Permutations with repetition

Computes the number of permutations with repetitions. That is, given a non-negative integer n and a sequence of one or more additional non-negative integers n1,...,nr such that n1++nr=n, this functions returns the number of permutations for nn elements taken from r different elements and such that the i-th element repeats ni times.

Syntax

permutations_with_repetition(Integer, Integer, ..., Integer)
permutations_with_repetition(Integer, List | Vector)

Description

Given an integer nn and a set of integers n1,...,nrn_1, ..., n_r satisfying the conditions above, computes the number of permutations for nn elements taken from rr different elements and such that the ii-th element repeats nin_i times.

combinatorics.permutations_with_repetition1.calc.png

Given an integer nn and a list or vector of nn elements, comprised of rr different elements and such that the ii-th element repeats nin_i times, returns a list of all the different distinct permutations (in lexicographical order).

combinatorics.permutations_with_repetition2.calc.png