Determinant Formula for derangement of $n$ numbers?

Solution 1:

It actually does not. For example, if $n=2$ then you get $-1$ instead of $1$. If you compute the permanent instead of the determinant then you do get the number of derangements. The permanent of $A$ is the sum over all "generalized diagonals" $a_{i\pi(i)}$ for all permutations $\pi$. In this case, the sum is $1$ if $\pi$ is a derangement, and $0$ otherwise.