Combinatorics

Factorials, binomials, permutations, combinations, at counting.

Choose and factorial in LaTeX: combinatorics symbols

To write “n choose k” in LaTeX, load amsmath and use \binom{n}{k}, which prints the binomial coefficient in parentheses and sizes itself for inline or display math; \dbinom and \tbinom force the large or small size. A factorial in LaTeX needs no command at all: n! is the letter and an exclamation mark, so the binomial formula is \frac{n!}{k!(n-k)!}. The table lists the combinatorics commands people use most, with the package each one needs; the full list of symbols follows below.

SymbolCommandUsePackageCopy
(nk)\binom{n}{k}
\binom{n}{k}n choose k (binomial coefficient)amsmath
(nk)\dbinom{n}{k}
\dbinom{n}{k}Display-size binomial, even inlineamsmath
(nk)\tbinom{n}{k}
\tbinom{n}{k}Text-size binomial, even in displayamsmath
(nk){n \choose k}
{n \choose k}Plain TeX choose (avoid with amsmath)built in
n!n!
n!Factorialbuilt in
n!!n!!
n!!Double factorialbuilt in
n!k!(n−k)!\frac{n!}{k!(n-k)!}
\frac{n!}{k!(n-k)!}Binomial coefficient formulabuilt in
(nk1,k2,…,km)\binom{n}{k_1, k_2, \ldots, k_m}
\binom{n}{k_1, k_2, \ldots, k_m}Multinomial coefficientamsmath
P(n,k)=n!(n−k)!P(n, k) = \frac{n!}{(n-k)!}
P(n, k) = \frac{n!}{(n-k)!}Permutations (nPr)built in
nk‾n^{\underline{k}}
n^{\underline{k}}Falling factorialbuilt in

Permutations, Stirling numbers and sums

Permutations are usually spelled out as P(n, k) or written with the falling factorial (n)_k or n^{\underline{k}}; the rising factorial is n^{\overline{k}} or the Pochhammer symbol (a)_n. Stirling numbers use bracket and brace versions of a binomial, built with amsmath’s \genfrac: \genfrac{\{}{\}}{0pt}{}{n}{k} for the second kind. Sums and products over index sets are \sum_{k=0}^{n} and \prod_{i=1}^{n}, and the size of a finite set is |A| or \lvert A \rvert.

Add \usepackage{amsmath} for \binom, \genfrac and \lvert; nothing here requires amssymb. For sums, products and fractions in general, see our guide to mathematical expressions in LaTeX.

Frequently asked questions

How do I write n choose k in LaTeX?
Load amsmath and write \binom{n}{k}, which prints n over k in parentheses and sizes itself for inline or display math. Use \dbinom{n}{k} to force the large display size and \tbinom{n}{k} for the small text size. The plain TeX form {n \choose k} also works, but amsmath warns against it.
How do I write a factorial in LaTeX?
A factorial needs no command: write n! in math mode. The double factorial is n!!, and for an expression wrap it in parentheses, as in (n+1)!. The binomial formula is \frac{n!}{k!(n-k)!}.
How do I write a multinomial coefficient in LaTeX?
Reuse \binom with a list in the lower argument: \binom{n}{k_1, k_2, \ldots, k_m}. Or write it out as \frac{n!}{k_1!\,k_2!\cdots k_m!}.
n!n!
(nk)\binom{n}{k}
C(n,k)C(n, k)
P(n,k)P(n, k)
(nk1,k2,…,km)\binom{n}{k_1, k_2, \ldots, k_m}

Multinomial

\binom{n}{k_1, k_2, \ldots, k_m}
(n)k(n)_k
n(k)n^{(k)}
[nk]\genfrac{[}{]}{0pt}{}{n}{k}

Stirling First Kind

\genfrac{[}{]}{0pt}{}{n}{k}
{nk}\genfrac{\{}{\}}{0pt}{}{n}{k}

Stirling Second Kind

\genfrac{\{}{\}}{0pt}{}{n}{k}
BnB_n
CnC_n
FnF_n
p(n)p(n)
DnD_n
n!!n!!
!n!n
(a)n(a)_n
∣A∣|A|