LCM in LaTeX (\text{lcm}(a, b))

lcm(a,b)\text{lcm}(a, b)
LaTeX command
\text{lcm}(a, b)
Package
Add to your preamble:\usepackage{amsmath}
Mode
Text and math mode

Where it is used

Least common multiple of a and b, the smallest positive integer both divide.

Unlike \gcd, there is no built-in \lcm command, which is why this entry uses \text. A preamble line \DeclareMathOperator{\lcm}{lcm} gives a proper operator with matching spacing, or use \operatorname{lcm} inline. The identity \gcd(a, b)\cdot\text{lcm}(a, b) = |ab| links the two. Least common multiples appear when adding fractions with different denominators, in the period of combined cycles, and in the order of an element of a product group. Some texts write [a, b] for the LCM, mirroring (a, b) for the GCD.

Minimal compilable example

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

gcd⁡(a,b)⋅lcm(a,b)=∣ab∣\gcd(a, b) \cdot \text{lcm}(a, b) = |ab|
\documentclass{article}
\usepackage{amsmath}
\begin{document}
LCM: $\text{lcm}(a, b)$

\[ \gcd(a, b) \cdot \text{lcm}(a, b) = |ab| \]
\end{document}

Related symbols

All Number Theory →

Frequently asked questions

How do I write LCM in LaTeX?
Type \text{lcm}(a, b) in math mode, for example $\gcd(a, b) \cdot \text{lcm}(a, b) = |ab|$. Load amsmath first with \usepackage{amsmath}.
Which package do I need for \text{lcm}(a, b)?
\text{lcm}(a, b) needs amsmath: add \usepackage{amsmath} to your preamble before the document starts.
Can I use \text{lcm}(a, b) in text mode, or only in math mode?
Both. \text{lcm}(a, b) compiles in running text as well as inside $...$; in a formula keep it in math mode so it gets math fonts and spacing.
Math poweredSumulat ng LaTeX gamit ang AI

Pinakamahusay na AI LaTeX Editor, Alternatibo sa Overleaf

Tinutulungan ng Octree ang mga researcher mula sa 15+ na unibersidad na sumulat ng research papers nang mas mabilis gamit ang AI

  • Gumawa ng magagandang TikZ diagrams gamit ang AI
  • Mag-upload ng larawan at i-convert ito sa LaTeX nang walang problema
  • Makakuha ng instant na tulong sa pagsulat at pag-format ng research papers