Join Nostr
2026-09-06 17:26:17 UTC

ygrek on Nostr: So apparently this is school #math for some kids but there is a thing called ...

So apparently this is school #math for some kids but there is a thing called subfactorial - how many permutations exist for N elements where none of the elements stay in the same position. There are several formulas how to compute it, i came up with quite an ugly one, but there is a very cute derivation for a simple formula `D(n)=(n-1)(D(n-1)+D(n-2))`, see https://en.wikipedia.org/wiki/Derangement . The thing that blew my mind is that it is precisely approximated by rounding `n! / e` - this is just insane.