LatexNotes

Factorial (n!) in LaTeX

A factorial is written as in handwriting, an exclamation mark after the number or letter: n! in maths mode, with no command needed.

LaTeX command

n!

Not the symbol you meant? Draw it to find the command →

Typing up handwritten notes? Convert a whole page of handwriting to LaTeX →

LaTeX treats ! after a letter as a closing symbol, so n! needs nothing extra. Two factorials side by side can look cramped; a thin space, n!\,m!, separates them. Bracket an expression before the mark: (n+1)!, never n+1!.

The double factorial, the product of every other number, is n!!. The falling factorial n(n-1)⋯(n-k+1) is written n^{\underline{k}} or (n)_k, and the rising factorial x^{\overline{k}} or x^{(k)}; notation varies between fields, so say which you use.

For non-integers, the gamma function extends the factorial: \Gamma(n+1) = n!. Large factorials are often approximated by Stirling's formula, shown below.

Other forms

n!!double factorial
n^{\underline{k}}falling factorial
x^{\overline{k}}rising factorial
\Gamma(n+1)the gamma function

Examples

$5! = 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1 = 120$

five factorial

$\binom{n}{k} = \frac{n!}{k!\,(n-k)!}$

the binomial coefficient, with a thin space

$7!! = 7 \cdot 5 \cdot 3 \cdot 1 = 105$

a double factorial

$n^{\underline{k}} = \frac{n!}{(n-k)!}$

the falling factorial

$\Gamma(n+1) = n!$

the gamma function

$n! \sim \sqrt{2\pi n}\left(\frac{n}{e}\right)^n$

Stirling's approximation

Tips and common mistakes

Working from handwritten notes?

LatexNotes turns a photo or PDF of handwritten mathematics into LaTeX, graphs and all. It is built with real pdflatex before you see it, and the .tex file is yours to edit or take to Overleaf. Free to try, no sign-up.

See how handwriting to LaTeX works, step by step, or go from GoodNotes to LaTeX if you write on an iPad (Notability works the same way).

Convert your maths to LaTeX →

FAQ

How do I write a factorial in LaTeX?

Type an exclamation mark after the number in maths mode, for example 5! or n!. No command is needed.

How do I write a double factorial?

Type two exclamation marks: n!!.

How do I write a falling factorial?

Write n^{\underline{k}} or (n)_k, and say which notation you are using.

Why does k!(n-k)! look cramped?

Two factorials sit close together. Add a thin space: k!\,(n-k)!.

See also