math

The Subfactorial is a variant of a factorial, denoted as . The subfactorial of n is the amount of permutations in which no element appears in its original position, also known as the number of derangements of a number.


The formula for calculating is:


where n is greater than or equal to 0.


Another way to find is: