Factorial in LaTeX (n!)

n!n!
LaTeX command
n!
Package
No package needed: built into LaTeX
Mode
Text and math mode

Where it is used

Factorial of n, the product of all positive integers up to n.

Typing n! needs no command: the exclamation mark prints directly in math mode, with 0! = 1 by convention. Factorials fill combinatorics and analysis, from \binom{n}{k} = \frac{n!}{k!(n-k)!} to Taylor coefficients \frac{f^{(n)}(a)}{n!}. Watch spacing in products like n!\,m!, where a thin space keeps the marks from crowding the next letter, and parenthesize compound arguments, (n+1)!. Do not confuse the character with \!, which is a negative thin space. Related notations include the double factorial n!! and Stirling's approximation n! \approx \sqrt{2\pi n}\,(n/e)^n.

Also listed under: التوافقيات

Minimal compilable example

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

(nk)=n!k! (n−k)!\binom{n}{k} = \frac{n!}{k!\,(n-k)!}
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Factorial: $n!$

\[ \binom{n}{k} = \frac{n!}{k!\,(n-k)!} \]
\end{document}

Related symbols

All الاحتمالات والإحصاء →

Frequently asked questions

How do I write Factorial in LaTeX?
Type n! in math mode, for example $\binom{n}{k} = \frac{n!}{k!\,(n-k)!}$. It works in plain LaTeX without loading any package.
Which package do I need for n!?
None. n! is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use n! in text mode, or only in math mode?
Both. n! compiles in running text as well as inside $...$; in a formula keep it in math mode so it gets math fonts and spacing.
Math poweredاكتب LaTeX باستخدام الذكاء الاصطناعي

أفضل محرر LaTeX بالذكاء الاصطناعي، بديل Overleaf

يساعد Octree الباحثين من أكثر من 15 جامعة على كتابة أوراق البحث بشكل أسرع باستخدام الذكاء الاصطناعي

  • أنشئ رسوم TikZ جميلة باستخدام الذكاء الاصطناعي
  • ارفع صورة وحولها إلى LaTeX بسلاسة
  • احصل على مساعدة فورية في كتابة وتنسيق أوراق البحث