Derangement in LaTeX (D_n)

DnD_n
LaTeX command
D_n
Package
No package needed: built into LaTeX
Mode
Math mode only

Where it is used

Derangement number D_n: permutations of n elements in which no element stays in its original position.

D_n counts permutations without fixed points and starts 1, 0, 1, 2, 9, 44, 265. Inclusion-exclusion gives D_n = n! \sum_{k=0}^{n} \frac{(-1)^k}{k!}, so D_n is the nearest integer to n!/e and the probability of a random derangement tends to 1/e. Recurrences include D_n = (n-1)(D_{n-1} + D_{n-2}). The classic story is the hat-check problem. The same number is also written !n, the subfactorial; D_n is easier to read in running text. Note D_n also names the dihedral group in algebra, so clarify if both appear.

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

Dn=n!∑k=0n(−1)kk!D_n = n! \sum_{k=0}^{n} \frac{(-1)^k}{k!}
\documentclass{article}
\begin{document}
Derangement: $D_n$

\[ D_n = n! \sum_{k=0}^{n} \frac{(-1)^k}{k!} \]
\end{document}

Related symbols

All 조합론 →

Frequently asked questions

How do I write Derangement in LaTeX?
Type D_n in math mode, for example $D_n = n! \sum_{k=0}^{n} \frac{(-1)^k}{k!}$. It works in plain LaTeX without loading any package.
Which package do I need for D_n?
None. D_n is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use D_n in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $D_n$ in running text.
Math poweredAI로 LaTeX 작성

최고의 AI LaTeX 편집기, Overleaf 대안

Octree는 15개 이상의 대학의 연구자들이 AI를 사용하여 논문을 더 빠르게 작성하도록 도움

  • AI로 아름다운 TikZ 다이어그램 생성
  • 이미지를 업로드하고 LaTeX로 원활하게 변환
  • 논문 작성 및 서식에 대한 즉각적인 지원 받기