Unit 2: Number Theory-II

MTH381 — Number Theory And Cryptography 4 min read

Number theory in this unit is built on divisibility over the integers: for integers and with , (" divides ") means for some integer . Every result below—factorisation, prime detection, greatest common divisors—rests on this single relation and on the ordering of the positive integers.

  • Universe of discourse: the positive integers and, for gcd/lcm, the integers .
  • Divisor: iff is an integer; if there is a nonzero remainder.
  • Division algorithm (foundational): for any integer and positive integer , there are unique integers (quotient) and (remainder) with and .
  • Trivial divisors: every has and as divisors; the theory classifies numbers by whether these are the only divisors.
  • Cryptographic stake: the practical hardness of factoring large integers, but the ease of multiplying primes, underlies public-key schemes such as RSA.

II. Primes and the Fundamental Theorem of Arithmetic

The atoms of multiplication and the uniqueness of their combination.

An integer's multiplicative structure is completely described by its prime constituents; this section defines those atoms and states the law that fixes them uniquely.

A. Primes

A prime is a building block that resists further multiplicative decomposition.

  • Definition: an integer is prime if its only positive divisors are and ; e.g. .
  • Composite: an integer that is not prime, so with ; e.g. .
  • Unit exclusion: is neither prime nor composite, so that factorisation is unique (allowing would let ).
  • Only even prime: is prime; every other even number has as a proper divisor.
  • Infinitude (Euclid): primes never run out. Suppose were all of them; then leaves remainder on division by each , so it has a prime factor outside the list—contradiction.

B. The fundamental theorem of arithmetic

Every integer above factors into primes in essentially one way.

  • Statement: every integer can be written as a product of primes, and this factorisation is unique up to the order of the factors.
  • Canonical form:
TEXT
n = p1^a1 · p2^a2 · ... · pk^ak,   p1 < p2 < ... < pk

where each is prime and each exponent .

  • Worked example: ; no other set of primes with exponents produces .
  • Existence: proved by strong induction—if is prime, done; if composite, with smaller factors, each already a product of primes.
  • Uniqueness: relies on Euclid's lemma—if then or .
  • Consequence for divisors and gcd: exponents in the factorisation drive every later computation; e.g. the number of positive divisors of is .

III. Locating Primes: Testing, Sieving, and Counting

Deciding primality, listing primes in bulk, and estimating how many there are.

Given the atoms of Section II, three procedures answer three distinct questions: is one number prime, which numbers up to a bound are prime, and roughly how dense are primes overall.

A. Trial division

Trial division tests a single integer for primality by attempting divisors directly.

  • Method: to test , divide by successive integers ; if any divides evenly, is composite, else prime.
  • bound: you need only test , because if then the smaller factor is at most .
  • Prime-only optimisation: it suffices to trial-divide by primes up to .
  • Worked example: test . , so try primes : none divides , so is prime.
  • Limitation: running time grows like , roughly operations for a -digit number, so it is hopeless for the large integers used in cryptography.

B. The sieve of Eratosthenes

The sieve generates all primes up to a limit by repeatedly eliminating multiples.

  • Principle: every composite has a prime factor ; strike out those multiples and the survivors are prime.
  • Procedure:
TEXT
list integers 2 .. N
p := 2
while p*p <= N:
    mark 2p, 3p, 4p, ... <= N as composite
    p := next unmarked number
unmarked numbers = primes
  • Start-at- optimisation: smaller multiples of (such as ) are already struck by earlier primes, so crossing out may begin at .
  • Worked example (N = 30): cross multiples of , then , then (since , stop). Survivors: .
  • Efficiency: produces all primes below in about operations—far cheaper per prime than trial-dividing each one separately.

C. The prime number theorem

The prime number theorem estimates how the primes thin out among large integers.

  • Notation: let denote the number of primes ; e.g. (namely ).
  • Statement:
TEXT
π(x) ~ x / ln x     as x → ∞

meaning the ratio .

  • Density reading: near a large , roughly in every integers is prime; primes get sparser but never stop.
  • Numeric check: for , , while the true —close, and the fit improves for larger .
  • Refined estimate: the logarithmic integral approximates even more accurately.
  • Significance: it guarantees a plentiful supply of large primes, so random search with a primality test reliably finds the primes cryptography needs.

IV. Greatest Common Divisors and Least Common Multiples

Shared and combined structure of two integers, and how to compute it.

Where Section II factored a single integer, this section relates a pair of integers through the divisors they share and the multiples they have in common.

A. Greatest common divisors and least common multiples

These two quantities capture the largest shared divisor and the smallest shared multiple.

  • gcd definition: is the largest positive integer dividing both and ; e.g. .
  • lcm definition: is the smallest positive integer that both and divide; e.g. .
  • Via factorisation: with and ,
TEXT
gcd(a,b) = ∏ p_i^{min(a_i, b_i)}
lcm(a,b) = ∏ p_i^{max(a_i, b_i)}
  • Product identity: , since .
  • Coprimality: and are relatively prime when ; e.g. .

B. The Euclidean algorithm

The Euclidean algorithm computes by repeated division, without any factorisation.

  • Key fact: where , because any common divisor of also divides .
  • Procedure:
TEXT
while b ≠ 0:
    r := a mod b
    a := b
    b := r
return a          # gcd
  • Worked example: : ; ; ; . Last nonzero remainder .
  • Efficiency: the number of divisions is —worst case arises with consecutive Fibonacci numbers—making it vastly faster than factoring large numbers.

C. Greatest common divisors as linear combinations

The gcd can be expressed as an integer combination of the two inputs, a fact known as Bézout's identity.

  • Statement (Bézout): there exist integers and with
TEXT
gcd(a,b) = s·a + t·b
  • Extended Euclidean algorithm: run the divisions above, then back-substitute each remainder to write the gcd in terms of and ; the coefficients are called Bézout coefficients.
  • Worked example (continuing ):
    • From : .
    • Substitute : .
    • Substitute : . So , .
  • Uses:
    • Modular inverses: if then , so is the inverse of modulo —the core computation for RSA key generation.
    • Linear Diophantine equations: has integer solutions iff , and Bézout supplies one.