Derangement Calculator

Enter n to count the derangements of n items.

From 0 to 1000.

Try

Result

You enteredn=0n = 0

!0=1\displaystyle !0 = 1

Probability

1\displaystyle 1
Show the work
  1. Derangements

    A derangement of n=0n = 0 items is an arrangement in which no item is in its original place. The count is written !n!n and follows from the inclusion–exclusion principle.

    Using !n=n!∑k=0n(−1)kk!!n = n! \sum_{k=0}^{n} \dfrac{(-1)^k}{k!}

  2. Recurrence for derangements

    Start from !0=1!0 = 1 and !1=0!1 = 0; each value then comes from the two before it.

    Using !n=(n−1)(!(n−1)+!(n−2))!n = (n - 1)\left(!(n-1) + !(n-2)\right)

  3. Probability that a random arrangement is a derangement

    Of the n!n! equally likely arrangements, !n!n have no item in place. As nn grows this probability approaches 1/e≈0.3678791/e \approx 0.367879.

    Using P=!nn!P = \dfrac{!n}{n!}

    11=1\frac{1}{1} = 1
  4. Result

    So !0=1!0 = 1.

Worked examples