Derangement in LaTeX (D_n)
- LaTeX command
D_n- Package
- No package needed: built into LaTeX
- Mode
- Math mode only
Try Derangement in a real LaTeX document
Open a ready-to-compile document that already uses D_n, with the right packages loaded. Edit it and see the PDF, no install needed.
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.
\documentclass{article}
\begin{document}
Derangement: $D_n$
\[ D_n = n! \sum_{k=0}^{n} \frac{(-1)^k}{k!} \]
\end{document}Related symbols
All Kombinatorika →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.
Editor LaTeX AI Terbaik, Alternatif Overleaf
Octree membantu peneliti dari 15+ universitas menulis makalah penelitian lebih cepat menggunakan AI
- Hasilkan diagram TikZ yang indah menggunakan AI
- Unggah gambar dan konversi ke LaTeX dengan mulus
- Dapatkan bantuan instan untuk menulis dan memformat makalah penelitian