Derangement Calculator

Enter n to count the derangements of n items.

From 0 to 1000.

Try

Result

You enteredn=10n = 10

!10=1334961\displaystyle !10 = 1334961

Probability

≈0.367879\displaystyle \approx 0.367879
Show the work
  1. Derangements

    A derangement of n=10n = 10 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, !5=44, !6=265, !7=1854, !8=14833, !9=133496, !10=1334961!0 = 1,\ !1 = 0,\ !2 = 1,\ !3 = 2,\ !4 = 9,\ !5 = 44,\ !6 = 265,\ !7 = 1854,\ !8 = 14833,\ !9 = 133496,\ !10 = 1334961
  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!}

    13349613628800≈0.367879\frac{1334961}{3628800} \approx 0.367879
  4. Result

    So !10=1334961!10 = 1334961.

Worked examples