Math Tools Math Tools

Number Theory Formulas

A reference of number theory formulas, grouped by category below. Every formula is typeset with KaTeX for clean, readable notation you can view online — click "Print" on any category to print it, or save it as a PDF straight from your browser's print dialog. Looking for a different subject? Browse the full list of math formula references.

Advertisement

Divisibility, GCD & LCM

$\gcd(a,b)\cdot\operatorname{lcm}(a,b)=a\cdot b$

$\gcd(a,b)=\gcd(b,\ a \bmod b)$

Euclidean algorithm

$a \mid b$

means $b=ka$ for some integer $k$

Modular Arithmetic

$a\equiv b \pmod{n}$

means $n \mid (a-b)$

$(a+b)\bmod n=[(a\bmod n)+(b\bmod n)]\bmod n$

$(a\cdot b)\bmod n=[(a\bmod n)\cdot(b\bmod n)]\bmod n$

Prime Numbers

$n=p_1^{e_1}p_2^{e_2}\cdots p_k^{e_k}$

fundamental theorem of arithmetic — prime factorization

$d(n)=(e_1+1)(e_2+1)\cdots(e_k+1)$

number of positive divisors of $n$

Euler's Totient

$\varphi(n)=n\prod_{p\mid n}\left(1-\frac{1}{p}\right)$

Euler's totient function

$a^{\varphi(n)}\equiv 1\pmod n$

Euler's theorem — $\gcd(a,n)=1$

Fermat's Little Theorem

$a^{p}\equiv a\pmod p$

$p$ is prime

$a^{p-1}\equiv 1\pmod p$

$p$ is prime, $\gcd(a,p)=1$

Advertisement