Derangement Calculator

Enter n to count the derangements of n items.

From 0 to 1000.

Try

Result

You enteredn=4n = 4

!4=9\displaystyle !4 = 9

Probability

0.375\displaystyle 0.375
Show the work
  1. Derangements

    A derangement of n=4n = 4 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)

    !0=1, !1=0, !2=1, !3=2, !4=9!0 = 1,\ !1 = 0,\ !2 = 1,\ !3 = 2,\ !4 = 9
  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!}

    924=0.375\frac{9}{24} = 0.375
  4. Result

    So !4=9!4 = 9.

Worked examples