This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)


gives the number of permutations of n objects that leave no object fixed.
  • Mathematical function, suitable for both symbolic and numerical manipulation.
  • Subfactorial can be evaluated to arbitrary numerical precision.
  • A permutation in which no object appears in its natural place is called a derangement.
Evaluate for large numbers:
Evaluate numerically for non-integer arguments:
Evaluate for complex arguments:
Evaluate to high precision:
The precision of the output tracks the precision of the input:
Subfactorial automatically threads over lists:
There are 9 derangements of a set of 4 objects:
Here are all permutations of the set :
Delete all permutations where an object is fixed:
Check that there are only 9 derangements:
Subfactorial[n] is given by :
Recurrence relations satisfied by Subfactorial:
The only number equal to the sum of subfactorials of its digits:
New in 6