Modulo in LaTeX (\pmod{n})

(modn)\pmod{n}
LaTeX command
\pmod{n}
Package
No package needed: built into LaTeX
Mode
Math mode only

Where it is used

Parenthesized 'mod n' after a congruence, giving the modulus.

Write a \equiv b \pmod{n} to state that n divides a - b. \pmod adds the parentheses and generous spacing before them, which suits displayed congruences. Its siblings serve other cases: \bmod is the binary operator for a remainder, as in a \bmod n = r; \mod gives the word mod without parentheses; and \pod gives only the parentheses. In inline text, the large space \pmod inserts can look excessive, so some authors switch to \bmod or a custom macro. Statements of the Chinese remainder theorem chain several congruences with different moduli.

Minimal compilable example

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

ap−1≡1(modp)a^{p-1} \equiv 1 \pmod{p}
\documentclass{article}
\begin{document}
Modulo: $\pmod{n}$

\[ a^{p-1} \equiv 1 \pmod{p} \]
\end{document}

Related symbols

All نظرية الأعداد →

Frequently asked questions

How do I write Modulo in LaTeX?
Type \pmod{n} in math mode, for example $a^{p-1} \equiv 1 \pmod{p}$. It works in plain LaTeX without loading any package.
Which package do I need for \pmod{n}?
None. \pmod{n} is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use \pmod{n} in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\pmod{n}$ in running text.
Math poweredاكتب LaTeX باستخدام الذكاء الاصطناعي

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

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

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