Yep, that's a precision problems. Try finding precise representations of your numbers (e.g. "e" constant has a precise and a less precise expression in many languages).
I've implemented what i've read in wikipedia (https://en.wikipedia.org/wiki/Derangement) but for the sample test (array length = 30) I get
97581073836835790093775590653952 should equal
I pass 8 of the 350 tests for array length up to 18. And after length 170 I return inf...
Aaaand the numbers I return for length between 18 and 170 are wrong.
Hey there! I really enjoyed the whole collection
Keep up the good work!