Subfactorial Calculator

Find the number of derangements of n items.

How to use

  1. Enter your values in the fields above.
  2. Press Calculate to see your result instantly.
  3. Use the Share button to copy a link to your result.

About this calculator

The subfactorial !n, also called the number of derangements of n, counts the permutations of n objects in which no object ends up in its original position. It's defined by !n = n! · Σ(k=0 to n) (−1)^k/k!, and grows very close to n!/e for large n — in fact !n is the nearest integer to n!/e. For example !4 = 9: out of the 24 permutations of 4 items, only 9 leave every item out of place.

The classic illustration is the "hat-check problem" (or "misaddressed letters problem"): if n people check their hats and they're returned randomly, !n is the number of ways every single person gets the wrong hat back. Combinatorics students, probability courses and puzzle enthusiasts use subfactorial calculations to solve derangement problems, and the concept extends into cryptography and coding theory wherever "nothing stays in its original slot" permutations matter.

Was this helpful?

Comments (0)

  • Be the first to comment.

Popular calculators

All Calculators