Derangement (SymPy, WMA)
Subfactorial[n]Here are the first few derangements:
Subfactorial[{0, 1, 2, 3}]
We can handle MachineReal numbers:
Subfactorial[6.0]
Here is how the exponential, Factorial, and Subfactorial grow in comparison:
LogPlot[{10^x, Factorial[x], Subfactorial[x]}, {x, 0, 25}, PlotPoints->26]