mk

Mathematics → Number Theory

Number Theory

Number theory studies the integers and their properties — divisibility, primes, and modular arithmetic. Gauss called it "the queen of mathematics," and its applications range from cryptography to coding theory.


Divisibility

Definition — Divisibility

An integer aa divides bb, written aba \mid b, if there exists an integer kk such that b=akb = ak. We say aa is a divisor (or factor) of bb.
312since12=34513since no integer k satisfies 13=5k3 \mid 12 \quad \text{since} \quad 12 = 3 \cdot 4 \qquad\qquad 5 \nmid 13 \quad \text{since no integer } k \text{ satisfies } 13 = 5k

Division Algorithm

For any integers aa and b>0b > 0, there exist unique integers qq (quotient) and rr (remainder) with 0r<b0 \le r < b such that:

a=bq+ra = bq + r

Example: dividing 17 by 5 gives 17=53+217 = 5 \cdot 3 + 2, so q=3q=3, r=2r=2.

Prime Numbers

Definition — Prime

An integer p>1p > 1 is prime if its only positive divisors are 1 and pp itself. An integer n>1n > 1 that is not prime is composite.

The first few primes: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, …

There are infinitely many primes — Euclid's proof by contradiction: assume finitely many primes p1,p2,,pnp_1, p_2, \ldots, p_n, then N=p1p2pn+1N = p_1 p_2 \cdots p_n + 1 is divisible by none of them, contradicting the assumption.

Sieve of Eratosthenes

To find all primes up to nn: list integers from 2 to nn, then repeatedly cross out multiples of each unmarked number. The survivors are prime. To check primality of nn, you only need to test divisors up to n\sqrt{n}.

GCD and LCM

Definition — GCD

The greatest common divisor gcd(a,b)\gcd(a,b) is the largest positive integer dividing both aa and bb. If gcd(a,b)=1\gcd(a,b) = 1, the integers are called coprime (or relatively prime).

Definition — LCM

The least common multiple lcm(a,b)\text{lcm}(a,b) is the smallest positive integer divisible by both aa and bb.

GCD and LCM are related by:

gcd(a,b)lcm(a,b)=ab\gcd(a,b) \cdot \text{lcm}(a,b) = |a \cdot b|

Example: gcd(12,18)=6\gcd(12,18)=6, lcm(12,18)=36\text{lcm}(12,18)=36, and 636=216=12186 \cdot 36 = 216 = 12 \cdot 18.

The Euclidean Algorithm

The Euclidean algorithm computes gcd(a,b)\gcd(a,b) efficiently using repeated division. It relies on the observation:

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

Applying this repeatedly until the remainder is zero:

gcd(48,18)=gcd(18,12)=gcd(12,6)=gcd(6,0)=6\gcd(48, 18) = \gcd(18, 12) = \gcd(12, 6) = \gcd(6, 0) = 6

The algorithm runs in O(logmin(a,b))O(\log \min(a,b)) steps — extremely efficient even for very large integers. It is the foundation of RSA and other public-key cryptosystems.

Modular Arithmetic

Definition — Congruence

Integers aa and bb are congruent modulo nn, written ab(modn)a \equiv b \pmod{n}, if n(ab)n \mid (a - b).
172(mod5)since 5(172)17 \equiv 2 \pmod{5} \qquad \text{since } 5 \mid (17 - 2)

Congruence is an equivalence relation. Arithmetic operations respect it:

ab(modn)   and   cd(modn)  a \equiv b \pmod{n} \;\text{ and }\; c \equiv d \pmod{n} \;\Rightarrow
a+cb+d(modn),acbd(modn)a + c \equiv b + d \pmod{n}, \qquad ac \equiv bd \pmod{n}

Modular arithmetic is the mathematics of clocks: on a 12-hour clock, 10+5=310 + 5 = 3 because 153(mod12)15 \equiv 3 \pmod{12}.

Fermat's Little Theorem

Theorem — Fermat's Little Theorem

If pp is prime and gcd(a,p)=1\gcd(a, p) = 1, then:
ap11(modp)a^{p-1} \equiv 1 \pmod{p}
Equivalently, for any integer aa: apa(modp)a^p \equiv a \pmod{p}.

This theorem is the cornerstone of RSA encryption. It also gives a fast way to compute modular inverses: since ap11a^{p-1} \equiv 1, the inverse of aa modulo pp is ap2modpa^{p-2} \bmod p.

Example: p=7, a=3p = 7,\ a = 3. Then 36=729=7104+13^6 = 729 = 7 \cdot 104 + 1, so 361(mod7)3^6 \equiv 1 \pmod 7. ✓

Fundamental Theorem of Arithmetic

Theorem — Fundamental Theorem of Arithmetic

Every integer n>1n > 1 can be written as a product of primes in exactly one way, up to ordering:
n=p1e1p2e2pkekn = p_1^{e_1}\, p_2^{e_2} \cdots p_k^{e_k}
where p1<p2<<pkp_1 < p_2 < \cdots < p_k are primes and ei1e_i \geq 1.
360=2332511001=71113360 = 2^3 \cdot 3^2 \cdot 5^1 \qquad 1001 = 7 \cdot 11 \cdot 13

This uniqueness is what makes primes the "atoms" of number theory. From the prime factorizations of aa and bb, one can directly read off gcd\gcd and lcm\text{lcm}: take the minimum (or maximum) exponent for each prime.


Next: Calculus →