Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a way to enumerate the $k$-permutations of a $n$ element set; that is, if $A=\left\{1, \dots, n\right\}$ and $K=\left\{(p_1, \dots, p_k)\mid p_i\in A\wedge i\neq j\implies p_i\neq p_j\right\}$; then I'd like a bijection

$f:\left\{1, \dots, \frac{n!}{(n-k)!}\right\}\to K$

along with it's inverse. In particular I'd like something computable rather than enumerative since clearly I could enumerate them by hand, but this becomes memory inefficient for large $n$ and $k$.

share|cite|improve this question
up vote 1 down vote accepted

You could us a partial Lehmer code: A number in mixed base $n,\dotsc,n-k+1$ that specifies which of the remaining slots is to be used in each of $k$ selection steps.

share|cite|improve this answer
I think I see (I use this for permutations of $n$ elements, so the $k=n$ case), just use the first $k$ digits and you still have a unique representation.. – Michael Conlen Oct 26 '12 at 19:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.