Number Theory

Search & glossary

Every rule and concept in Number Theory, with its definition and a link to the lesson that teaches it. Search by term, by idea, or by lesson title.

Glossary (37)

(p−1)!≡−1(p - 1)! \equiv -1
Wilson: for a prime pp, $(p - 1)!
Fermat, Euler and Wilson › Wilson's Theorem
gcd⁡⋅lcm=ab\gcd\cdot\text{lcm} = ab
The least common multiple lcm(a,b)\text{lcm}(a, b) is the smallest positive integer divisible by both.
GCD, LCM and the Euclidean Algorithm › LCM and the Product Formula
ap−1≡1a^{p-1} \equiv 1
If pp is prime and p∤ap \nmid a, then ap−1≡1(modp)a^{p-1} \equiv 1 \pmod p; equivalently ap≡aa^p \equiv a for every aa.
Fermat, Euler and Wilson › Fermat's Little Theorem
ax+by=cax + by = c
The equation ax+by=cax + by = c has integer solutions iff gcd⁡(a,b)∣c\gcd(a, b) \mid c.
Diophantine Equations › Linear Diophantine Equations
A generator
A primitive root mod mm is an element of order exactly φ(m)\varphi(m).
Orders and Primitive Roots › Primitive Roots
Cancellation
If ac≡bc(modm)ac \equiv bc \pmod m and gcd⁡(c,m)=1\gcd(c, m) = 1, then a≡b(modm)a \equiv b \pmod m.
Modular Arithmetic › Inverses and Linear Congruences
Carry at bb
Addition and multiplication work column by column in any base, exactly as in base ten, except that a column carries when it reaches bb instead of 1010.
Digits and Bases › Arithmetic in Other Bases
Check every class
To prove a statement about all integers nn whose truth depends only on n mod mn \bmod m, check the mm residues 0,1,…,m−10, 1, \ldots, m - 1.
Modular Arithmetic › Proofs by Residue Classes
Consistency first
If the moduli share factors, the system x≡a1(modm1)x \equiv a_1 \pmod{m_1}, x≡a2(modm2)x \equiv a_2 \pmod{m_2} has a solution iff a1≡a2(modgcd⁡(m1,m2))a_1 \equiv a_2 \pmod{\gcd(m_1, m_2)}, and the solution is then unique mod lcm(m1,m2)\text{lcm}(m_1, m_2) — not mod m1m2m_1m_2.
The Chinese Remainder Theorem › Moduli That Share a Factor
Count the dots two ways
A sum of floors counts lattice points: ⌊qk/p⌋\lfloor qk/p \rfloor is the number of points (k,j)(k, j) with 1≤j≤qk/p1 \le j \le qk/p, the points on or under the line y=qx/py = qx/p above x=kx = k.
Hard Number Theory › Floor Sums and Lattice Points
Definition and infinitude
A prime is an integer p>1p > 1 whose only positive divisors are 11 and pp; an integer n>1n > 1 that is not prime is composite.
Primes and Factorization › Primes
Digit sums and 99
A number and its digit sum are congruent mod 99.
Digits and Bases › Digit Problems
Digit tests
A number is divisible by 2,5,102, 5, 10 according to its last digit; by 44 or 2525 according to its last two digits; by 88 by its last three.
Divisibility › Divisibility Rules
Digits as unknowns
A two-digit number with digits a,ba, b is 10a+b10a + b; reversing gives 10b+a10b + a; their difference is 9(a−b)9(a - b).
Digits and Bases › Digit Problems
Divides, quotient, remainder
We write a∣ba \mid b ("aa divides bb") when b=akb = ak for some integer kk.
Divisibility › The Division Algorithm
Euler's totient
φ(m)\varphi(m) counts the integers in 1,…,m1, \ldots, m coprime to mm.
Fermat, Euler and Wilson › Euler's Theorem and φ\varphi
Every integer, every base
For any base b≥2b \ge 2, every positive integer has a unique representation n=dkbk+⋯+d1b+d0n = d_kb^k + \cdots + d_1b + d_0 with digits 0≤di<b0 \le d_i < b, written dk⋯d1d0‾b\overline{d_k\cdots d_1d_0}_b.
Digits and Bases › Base bb Representation
Independent moduli combine
If m1,…,mkm_1, \ldots, m_k are pairwise coprime, the system x≡ai(modmi)x \equiv a_i \pmod{m_i} has exactly one solution mod M=m1⋯mkM = m_1\cdots m_k.
The Chinese Remainder Theorem › CRT
Legendre's formula
The exponent of a prime pp in n!n! is ⌊np⌋+⌊np2⌋+⌊np3⌋+⋯\left\lfloor\dfrac np\right\rfloor + \left\lfloor\dfrac n{p^2}\right\rfloor + \left\lfloor\dfrac n{p^3}\right\rfloor + \cdots, a sum that stops once pk>np^k > n.
Primes and Factorization › Factorials and Legendre's Formula
Let the equation pick the modulus
A modulus is useful when the terms of the equation take few values in it.
Hard Number Theory › Choosing a Modulus
Modular inverses
aa has an inverse mod mm (a number a−1a^{-1} with aa−1≡1aa^{-1} \equiv 1) exactly when gcd⁡(a,m)=1\gcd(a, m) = 1; find it from Bézout.
Modular Arithmetic › Inverses and Linear Congruences
Multiplicative functions
τ(n)\tau(n) counts the divisors of nn, σ(n)\sigma(n) sums them, φ(n)\varphi(n) counts the residues coprime to nn.
Arithmetic Functions › τ\tau, σ\sigma and φ\varphi
No solution mod mm, no solution at all
If an equation has an integer solution, reducing it gives a solution modulo every mm.
Diophantine Equations › Congruence Obstructions
Order
For gcd⁡(a,m)=1\gcd(a, m) = 1, the order of aa mod mm is the least d>0d > 0 with ad≡1a^d \equiv 1.
Orders and Primitive Roots › The Order of an Element
Period of 1/p1/p
The decimal expansion of 1/p1/p (p≠2,5p \ne 2, 5) has period equal to the order of 1010 modulo pp.
Orders and Primitive Roots › The Order of an Element
Reading off structure
Questions like "which nn have exactly 66 divisors?" are questions about exponent patterns: 6=66 = 6 or 2⋅32\cdot3, so n=p5n = p^5 or n=p2qn = p^2q.
Arithmetic Functions › Divisor Problems
Repeated remainders
Since gcd⁡(a,b)=gcd⁡(b,a mod b)\gcd(a, b) = \gcd(b, a \bmod b), dividing repeatedly and keeping remainders reaches gcd⁡(a,b)\gcd(a, b) as the last nonzero remainder.
GCD, LCM and the Euclidean Algorithm › The Euclidean Algorithm
Simon's Favorite Factoring Trick
xy+ax+by=cxy + ax + by = c becomes (x+b)(y+a)=c+ab(x + b)(y + a) = c + ab: add the missing constant to complete the product, then list factor pairs.
Diophantine Equations › Factoring and Bounding
Split, solve, reassemble
To compute something mod a composite m=m1m2m = m_1m_2 with gcd⁡(m1,m2)=1\gcd(m_1, m_2) = 1, compute it mod m1m_1 and mod m2m_2 separately — often much easier, for instance by Fermat on each prime — and then combine the two remainders with CRT.
The Chinese Remainder Theorem › Computing with CRT
Squares mod pp
For an odd prime pp, exactly half of the nonzero residues are squares (quadratic residues).
Orders and Primitive Roots › Quadratic Residues
Summing over d∣nd \mid n
Many identities sum a function over the divisors of nn.
Arithmetic Functions › Sums and Products over Divisors
The combination rule
If a∣ba \mid b and a∣ca \mid c, then a∣bx+cya \mid bx + cy for all integers x,yx, y.
Divisibility › Combining Divisibility Facts
The gcd from factorizations
The greatest common divisor gcd⁡(a,b)\gcd(a, b) is the largest integer dividing both aa and bb.
GCD, LCM and the Euclidean Algorithm › Greatest Common Divisors
The gcd is a combination
For integers a,ba, b not both zero there exist integers x,yx, y with ax+by=gcd⁡(a,b)ax + by = \gcd(a, b).
GCD, LCM and the Euclidean Algorithm › Bézout's Identity
The toolkit in one place
Hard number theory problems combine a few moves: reduce mod a well-chosen modulus to rule out solutions; factor (SFFT, difference of squares, sums of cubes); bound a variable by size or by the growth of a power; use orders to control exponents; and apply Fe…
Hard Number Theory › Strategy
Unique factorization
Every integer n>1n > 1 is a product of primes, and the factorization is unique up to order: n=p1e1p2e2⋯pkekn = p_1^{e_1}p_2^{e_2}\cdots p_k^{e_k}.
Primes and Factorization › The Fundamental Theorem of Arithmetic
Working mod mm
a≡b(modm)a \equiv b \pmod m means m∣(a−b)m \mid (a - b): aa and bb leave the same remainder on division by mm.
Modular Arithmetic › Congruences