Skip to content
ENExplore Calculators

Subfactorial Calculator

Work out subfactorial instantly with clear inputs, formula shown and shareable results.

About Subfactorial Calculator

The subfactorial !n counts derangements — permutations leaving no item in its original place. It satisfies the recurrence !n = n·!(n−1) + (−1)ⁿ, and !n / n! tends to 1/e ≈ 0.3678794.

Formulas

Derangement recurrence

!n = n·!(n−1) + (−1)ⁿ, with !0 = 1

Limit

!n / n! → 1/e

Worked example

With the default values below, Subfactorial Calculator returns Subfactorial !n (derangements) of 265. Change any input above and every figure here is recalculated in your browser.

Inputs used

Number of items naccepts 0–170
6
Compare with n =accepts 0–170
7

Results

Subfactorial !n (derangements)
265
Total permutations n!
720
Comparison subfactorial
1,854
Probability a random permutation is a derangement
0.36805556

Step by step

  1. 1Values used
  2. 2Derangement recurrence
  3. 3Limit
  4. 4Subfactorial !n (derangements)= 265
  5. 5Total permutations n!= 720
  6. 6Comparison subfactorial= 1,854
  7. 7Probability a random permutation is a derangement= 0.36805556

Assumptions and limits

  • The result is derived only from the 2 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to 8 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

What is !6?

265, out of 720 total permutations, a probability of about 0.368.

What is the hat-check problem?

If n people collect hats at random, the chance nobody gets their own is !n/n!, which is essentially 1/e for any n above about 5.

Subfactorial Calculator | Calcrivo