Reference notes.

Number theory is the study of integers and their properties. Often called “the queen of mathematics,” it has surprising applications in cryptography and computer science.

Divisibility

Basic Definitions

  • divides (written ) if for some integer
  • Properties:
    • Reflexive:
    • Transitive: if and , then
    • If and , then for any integers

Division Algorithm

For any integers with , there exist unique integers (quotient) and (remainder) such that:

Greatest Common Divisor (GCD)

For integers not both zero, the greatest common divisor is the largest positive integer that divides both and ; by convention, .

Properties:

  • (for )

Euclidean Algorithm (for integers ; taking handles negative inputs):

gcd(a, b):
    while b ≠ 0:
        a, b = b, a mod b
    return |a|

Least Common Multiple (LCM)

For non-zero integers , the least common multiple is the smallest positive integer divisible by both and (with by convention).

Key relationship (for not both zero):

Bézout’s Identity

For any integers and , there exist integers and such that:

The Extended Euclidean Algorithm computes both and the coefficients .

Prime Numbers

Fundamental Theorem of Arithmetic

Every integer greater than can be expressed uniquely as a product of prime numbers (up to ordering).

For example:

Properties of Primes

  • There are infinitely many primes (Euclid’s proof by contradiction)
  • The prime counting function counts primes
  • Prime Number Theorem: as

Testing Primality

MethodTypeComplexity
Trial divisionDeterministic divisions
Miller-RabinProbabilistic bit operations
AKSDeterministic bit operations (Lenstra–Pomerance)

Finding Primes

Sieve of Eratosthenes:

  1. List integers from to
  2. Mark as prime, cross out all multiples of
  3. Find next unmarked number, mark as prime, cross out its multiples
  4. Repeat up to

Sieve of Atkin: A more efficient modern sieve with complexity .

Special Primes

  • Mersenne primes: primes of the form where is prime (e.g. )
  • Fermat primes: primes of the form (only five known: ; is composite)
  • Twin primes: pairs where both are prime (e.g. and )
  • Sophie Germain primes: primes where is also prime

Modular Arithmetic

Congruences

For a positive integer modulus , we say if , i.e. and have the same remainder when divided by .

Properties (congruence is an equivalence relation):

  • Reflexive:
  • Symmetric: if , then
  • Transitive: if and , then

Arithmetic:

Residue Systems

  • Complete residue system mod : e.g. the least non-negative residue system
  • Reduced residue system mod : elements coprime to
    • For :

Linear Congruences

To solve ():

  • Solvable if and only if
  • If solvable with , there are exactly incongruent solutions modulo
  • Use the Extended Euclidean Algorithm to find solutions

Chinese Remainder Theorem

Given a system of congruences (with moduli ):

If the moduli are pairwise coprime, there exists a unique solution modulo .

Important Theorems

Fermat’s Little Theorem

If is prime and :

Equivalently: for all integers .

Euler’s Theorem

If and :

This generalises Fermat’s Little Theorem.

Euler’s Totient Function

For , counts integers with and .

Formulas:

  • for prime
  • for prime and integer
  • if (multiplicative)
  • over all distinct prime divisors of
Reduced residues

Wilson’s Theorem

An integer is prime if and only if:

Diophantine Equations

Linear Diophantine Equations

For integers not both zero, the equation has integer solutions if and only if .

If is a particular solution, the general solution is:

where and .

Pythagorean Triples

Positive integer solutions to .

Primitive solutions () are given (up to swapping and ) by:

where , , and is odd.

Examples: , , ,

Fermat’s Last Theorem

The equation has no positive integer solutions for any integer .

Conjectured by Pierre de Fermat in 1637, proved by Andrew Wiles in 1995 after 358 years.

Pell’s Equation

For a non-square positive integer , the equation has infinitely many integer solutions.

The fundamental solution can be found using continued fractions.

Example: has solutions , , , ,

Cryptographic Applications

RSA Algorithm

The RSA cryptosystem relies on the difficulty of factorising large integers.

Key Generation:

  1. Choose two distinct large primes
  2. Compute (modulus)
  3. Compute
  4. Choose with and (commonly )
  5. Compute using the Extended Euclidean Algorithm

Keys:

  • Public key:
  • Private key:

Operations:

  • Encrypt:
  • Decrypt:

Security depends on the infeasibility of factorising to recover and .

Diffie-Hellman Key Exchange

Allows two parties to establish a shared secret over an insecure channel.

Based on the discrete logarithm problem: given , finding is computationally hard.

Elliptic Curve Cryptography

Uses the group structure of points on elliptic curves over finite fields.

Advantages: smaller key sizes for equivalent security compared to RSA.

Quadratic Residues

Definition

An integer is a quadratic residue modulo if the congruence has a solution.

For an odd prime , exactly of the non-zero residues modulo are quadratic residues.

Legendre Symbol

For an odd prime and an integer not divisible by :

Euler’s criterion:

Quadratic Reciprocity

For distinct odd primes and :

This means unless both .

Supplementary laws:

Learning Resources

Books

  • A Friendly Introduction to Number Theory by Joseph Silverman
  • An Introduction to the Theory of Numbers by Hardy and Wright
  • Elementary Number Theory by David Burton
  • Number Theory: A Lively Introduction by James Pommersheim

Online Courses