Subfactorial Calculator

!n = n! · Σ(-1)^k/k!

CalculatorsFreeNo Signup
4.4(525 reviews)
All Tools

Loading tool...

About Subfactorial Calculator

A subfactorial calculator computing !n = n!·Σ(-1)^k/k! for k=0..n. Equivalent to the number of derangements. Shows the inclusion-exclusion formula, ratio to n!, and the nearest integer formula !n = round(n!/e). Client-side.

Subfactorial Calculator Features

  • !n formula
  • Inclusion-exclusion
  • Ratio to n!
  • Round(n!/e)
  • Sequence
Subfactorial !n counts derangements — permutations where no element stays in place. !0=1, !1=0, !2=1, !3=2, !4=9, !5=44... = round(n!/e). Also: !n = (n-1)(!(n-1)+!(n-2)). The probability of a random permutation being a derangement → 1/e ≈ 36.8%.

How to Use

Enter n:

  • !n: Subfactorial value
  • n!: For comparison
  • Ratio: !n/n! → 1/e

Hat Check Problem

n guests check hats. Hats returned randomly. What's the probability NO ONE gets their own hat? Answer: !n/n! → 1/e. Even for n=5, it's already !5/120 = 44/120 ≈ 36.7%.

Formulas

  • !n = n! · Σ(-1)^k/k! (k=0..n)
  • !n = round(n!/e)
  • !n = (n-1)·(!(n-1)+!(n-2))
  • !n = n·!(n-1) + (-1)^n

Step-by-Step Instructions

  1. 1Enter n.
  2. 2Compute !n.
  3. 3Compare to n!.
  4. 4Check ratio.
  5. 5Browse sequence.

Subfactorial Calculator — Frequently Asked Questions

What's the difference between subfactorial and derangement?+

They're the same thing! !n = D(n) = number of derangements of n elements. 'Subfactorial' is the name of the function; 'derangement' describes the corresponding permutation. Both count permutations with zero fixed points.

Why does !n/n! approach 1/e?+

The formula !n = n!·Σ(-1)^k/k! (k=0..n) is a partial sum of the Taylor series for e^(-1). As n→∞, this partial sum → 1/e. So !n/n! → 1/e = 0.36788... The convergence is extremely fast.

Is there a simple recurrence?+

Yes! !n = (n-1)(!(n-1) + !(n-2)). Interpretation: element n goes to position i (n-1 choices), then either i goes to n's position (!(n-2) remaining derangements) or not (!(n-1) remaining). Beautiful combinatorial argument!

Share this tool: