Number theory is the branch of pure mathematics studying the integers and integer-valued functions. Classical results about primes and divisibility underlie modern cryptography and computer science.
1. Integers and Divisibility¶
For integers and with , we say divides (written ) if there exists an integer such that .
1.1 Division Algorithm¶
For any integers and , there exist unique integers (quotient) and (remainder) with such that:
1.2 Greatest Common Divisor (GCD)¶
The GCD of two integers (not both zero) is the largest positive integer dividing both.
Euclidean algorithm — the most efficient classical method:
Least Common Multiple:
Bézout’s identity: There always exist integers such that
These coefficients are found by the extended Euclidean algorithm.
2. Prime Numbers¶
An integer is prime if its only positive divisors are 1 and itself. Otherwise is composite.
2.1 Fundamental Theorem of Arithmetic¶
Every integer has a unique prime factorisation:
2.2 Density of Primes — Prime Number Theorem¶
Let denote the number of primes . Then:
so primes become increasingly sparse, but there are infinitely many of them (Euclid’s proof).
2.3 Sieve of Eratosthenes¶
To find all primes up to :
List integers .
Start at ; mark all multiples of greater than as composite.
Move to the next unmarked number and repeat.
Stop when ; all unmarked numbers are prime.
2.4 Special Primes¶
| Type | Definition | Examples |
|---|---|---|
| Mersenne prime | 3, 7, 31, 127 | |
| Fermat prime | 3, 5, 17, 257, 65537 | |
| Twin primes | both prime | (3,5), (11,13), (17,19) |
| Sophie Germain prime | and both prime | 2, 3, 5, 11, 23 |
3. Modular Arithmetic¶
For a positive integer (the modulus), (read “ is congruent to modulo ”) if .
Congruence behaves like equality with respect to addition and multiplication:
3.1 Residue Classes¶
The integers modulo form the set with operations defined mod . is a field (every nonzero element has a multiplicative inverse) if and only if is prime.
3.2 Fermat’s Little Theorem¶
If is prime and :
Equivalently for any integer : . This is the basis of the Fermat primality test and RSA encryption.
3.3 Euler’s Theorem¶
For :
where is Euler’s totient function — the count of integers in coprime to .
For :
3.4 Chinese Remainder Theorem (CRT)¶
If are pairwise coprime, then for any the system
has a unique solution modulo .
4. Diophantine Equations¶
A Diophantine equation is a polynomial equation for which integer (or rational) solutions are sought.
4.1 Linear Diophantine Equations¶
has integer solutions if and only if . If a solution exists, the general solution is:
4.2 Pythagorean Triples¶
All positive integer solutions to (with , ) are generated by:
for integers with and .
4.3 Pell’s Equation¶
(where is a positive non-square integer) always has infinitely many solutions. The fundamental solution is found from the continued fraction expansion of .
5. Number-Theoretic Functions¶
| Function | Symbol | Definition |
|---|---|---|
| Euler’s totient | ||
| Divisor count | or | Number of positive divisors of |
| Divisor sum | Sum of all positive divisors of | |
| Möbius function | 0 if ; if ; 1 if | |
| Liouville function | where = total prime factors with multiplicity |
All these functions are multiplicative: if then .
6. Continued Fractions¶
Any real number can be expressed as a continued fraction:
denoted , where the are positive integers for .
Rational numbers have finite continued fractions.
Quadratic irrationals (like ) have infinite periodic continued fractions.
Transcendental numbers like have no periodic pattern.
The partial quotients are called convergents and provide the best rational approximations to .
7. Rational and Irrational Numbers¶
A rational number can be written as with , . Their decimal expansions are terminating or eventually repeating.
An irrational number cannot be expressed as a ratio of integers. Famous examples:
— proved irrational by Pythagoras; is irrational for every prime
— also transcendental (not a root of any polynomial with integer coefficients)
— transcendental (Hermite, 1873)
The set of real numbers is uncountable (Cantor’s diagonal argument), while the rationals are countable.
8. Cryptographic Applications¶
Number theory provides the mathematical foundation for public-key cryptography.
RSA Encryption (sketch)¶
Choose large primes and set .
Compute .
Choose public exponent with .
Find private exponent satisfying .
Encrypt: . Decrypt: .
Security rests on the difficulty of integer factorisation of when and are large.
Diffie–Hellman Key Exchange (sketch)¶
Based on the discrete logarithm problem: given , (prime), and , find . This is believed to be computationally hard for large .
This is a placeholder for Number Theory content.