Partial Derangement

Author

Eric W. Weisstein
November 4, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Combinatorics/PartialDerangement.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/PartialDerangement.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Code

R[n_,n_]:=1
R[n_,k_/;k==n-1]:=0
R[n_,k_]:=Binomial[n,k]Subfactorial[n-k]

Enumeration

Table[R[n,k],{n,0,6},{k,0,n}]//ColumnForm

Solution

RSolve[{R[n,k]==Binomial[n,k]Subfactorial[n-k],R[n,n]==1,R[n,n-1]==0},R[n,k],{n,k}]