powered by
count.derangements(perm.length)
count.derangements(4)
Run the code above in your browser using DataLab