Frankly, it took me a bit of time to reconcile this formula with the one I know.
I know this one:
D(n) is the number of derangements of a string of n objects.
That is, a rearrangement in which none of the n is in its correct place.
Now your given will give an incorrect answer if .
But if you change the index to begin at 0: then .