정수론

가분성, 모듈러 산술 및 정수론적 함수.

Number theory symbols in LaTeX

Modulus and mod in LaTeX come in a few forms: \bmod for a remainder, \pmod{n} after a congruence, and \lvert z \rvert for the modulus (absolute value) of a number. The table lists the eight commands people use most, with the package each one needs; the full list of number theory symbols follows below.

SymbolCommandUsePackageCopy
a mod na \bmod n
a \bmod nModulo as a binary operationbuilt in
a≡b(modn)a \equiv b \pmod{n}
a \equiv b \pmod{n}Congruence with (mod n)built in
a≡bmod  na \equiv b \mod{n}
a \equiv b \mod{n}Congruence without parenthesesamsmath
∣z∣\lvert z \rvert
\lvert z \rvertModulus / absolute valueamsmath
a∣ba \mid b
a \mid ba divides bbuilt in
a∤ba \nmid b
a \nmid ba does not divide bamssymb
gcd⁡(a,b)\gcd(a, b)
\gcd(a, b)Greatest common divisorbuilt in
lcm⁡(a,b)\operatorname{lcm}(a, b)
\operatorname{lcm}(a, b)Least common multipleamsmath

Divisibility is the symbol people search for most: a \mid b means a divides b, and \nmid (from amssymb) negates it. Use \mid rather than a plain bar so LaTeX treats it as a relation with the right spacing. Congruences use \equiv together with \pmod{n}, which adds the parentheses and spacing for you: a \equiv b \pmod{n}. Inline remainders use \bmod, as in a \bmod n.

The greatest common divisor has its own operator, \gcd(a, b); the least common multiple does not, so write \operatorname{lcm}(a, b) with amsmath. Euler’s totient is \varphi(n) (or \phi(n)), the Möbius function is \mu(n), the divisor function is \sigma(n), and the prime-counting function is \pi(x). Floor and ceiling are \lfloor x \rfloor and \lceil x \rceil, and the Legendre symbol is a fraction in parentheses: \left(\frac{a}{p}\right). Sums over divisors read naturally as \sum_{d \mid n} f(d).

The number sets \mathbb{N}, \mathbb{Z}, \mathbb{Q} and \mathbb{Z}/n\mathbb{Z} need \usepackage{amssymb} (or amsfonts). Read more about blackboard bold in our guide to the real numbers symbol and the overview of mathematical expressions in LaTeX.

Frequently asked questions

How do I write mod (modulo) in LaTeX?
Use \bmod for the binary operation, as in a \bmod n, and \pmod{n} after a congruence: a \equiv b \pmod{n} adds the parentheses and spacing for you. amsmath also provides \mod{n} (no parentheses) and \pod{n} (parentheses without the word mod).
How do I write the modulus (absolute value) in LaTeX?
Write \lvert z \rvert with amsmath, or \left| z \right| when the bars should grow with tall content. For frequent use, mathtools lets you declare \DeclarePairedDelimiter{\abs}{\lvert}{\rvert} and then write \abs{z}.
How do I write “divides” in LaTeX?
Use \mid, as in a \mid b, which LaTeX spaces as a relation; a plain | is too tight. The negation \nmid (a does not divide b) needs \usepackage{amssymb}.
∣\mid
∤\nmid
gcd⁡(a,b)\gcd(a, b)

GCD

\gcd(a, b)
lcm(a,b)\text{lcm}(a, b)

LCM

\text{lcm}(a, b)
≡\equiv

Congruent

\equiv
(modn)\pmod{n}

Modulo

\pmod{n}
φ(n)\varphi(n)

Euler Phi

\varphi(n)
ϕ(n)\phi(n)
pp
pnp_n
⊥\perp

Coprime

\perp
(ap)\left(\frac{a}{p}\right)

Legendre Symbol

\left(\frac{a}{p}\right)
⌊x⌋\lfloor x \rfloor

Floor

\lfloor x \rfloor
⌈x⌉\lceil x \rceil

Ceiling

\lceil x \rceil
[x][x]
{x}\{x\}
σ(n)\sigma(n)
μ(n)\mu(n)
d(n)d(n)