Search Knowledge

© 2026 LIBREUNI PROJECT

Mathematics / Number Systems & Theory

Number Theory and Modular Arithmetic

Elementary and Analytic Number Theory

Number theory, historically termed “Higher Arithmetic,” serves as the cornerstone of mathematical abstraction, exploring the properties of the set of integers . While its foundations are elementary, its deep connections to complex analysis, abstract algebra, and cryptography make it one of the most vibrant fields of modern mathematics.

Divisibility and the Euclidean Algorithm

The core of number theory begins with the concept of divisibility. For , we say divides (written ) if there exists an integer such that .

The Division Algorithm

Technically a theorem rather than an algorithm, it states that for any and , there exist unique integers (quotient) and (remainder) such that:

Greatest Common Divisor (GCD)

The GCD of and , denoted , is the largest positive integer such that and . Two numbers are coprime or relatively prime if .

The Euclidean Algorithm

To compute , we exploit the invariant .

  1. Let and .
  2. Compute until .
  3. The last non-zero remainder is the .

Bézout’s Identity and the Extended Euclidean Algorithm

For any , there exist such that: This is fundamental for finding modular inverses. If , then has a solution, where is the multiplicative inverse of modulo .

Primes and the Fundamental Theorem of Arithmetic

A prime number is an integer whose only positive divisors are and . If is not prime, it is composite.

The Fundamental Theorem of Arithmetic

Every integer can be uniquely represented as a product of prime numbers: where are primes and .

Distribution of Primes

Euclid proved that there are infinitely many primes by contradiction: if there were a finite set , then would have a prime factor not in the set. The Prime Number Theorem (PNT) provides the asymptotic density: where is the prime-counting function.

Modular Arithmetic

Modular arithmetic is a system of arithmetic for integers, where numbers “wrap around” when reaching a certain value, the modulus .

Congruence Relation

We say if . This is an equivalence relation that partitions into equivalence classes, often denoted .

Fermat’s Little Theorem

If is prime and is an integer such that , then: Generalizing this, we use the Euler Totient Function , which counts the integers such that and .

Euler’s Theorem

For any such that :

Chinese Remainder Theorem (CRT)

If are pairwise relatively prime, then the system of simultaneous congruences: has a unique solution modulo .

Multiplicative Functions and Mobius Inversion

A function is multiplicative if for all with .

  1. Sum of Divisors: .
  2. Number of Divisors: .
  3. Mobius Function: , used for the Mobius Inversion Formula.
    • if .
    • if is the product of distinct primes.
    • if has a squared prime factor.

Quadratic Reciprocity

One of the deepest results in elementary number theory is the Law of Quadratic Reciprocity. It describes whether a prime is a quadratic residue modulo another prime . The Legendre Symbol is defined as:

  • if is a quadratic residue modulo ( has a solution).
  • if is a quadratic non-residue.
  • if .

The law states for odd primes :

Cryptographic Applications: RSA

The RSA algorithm is the most ubiquitous application of number theory in computing. It relies on the computational difficulty of the Integer Factorization Problem.

RSA Key Generation

  1. Choose two large distinct primes and .
  2. Compute and .
  3. Choose an integer such that and (usually ).
  4. Compute as the modular multiplicative inverse of using the Extended Euclidean Algorithm: .
  5. Public Key is ; Private Key is .

Encryption and Decryption

  • Encryption: For message , .
  • Decryption: . The correctness follows from Euler’s Theorem, ensuring .

Primality Testing

In cryptography, we must find large primes. Deterministic tests like the Sieve of Eratosthenes are and too slow.

  • Miller-Rabin Test: A probabilistic test based on strong pseudoprimes and Fermat’s Little Theorem. It is very efficient and widely used.
  • AKS Test: The first deterministic polynomial-time algorithm to determine if a number is prime, discovered in 2002.

Computational Perspective: Extended Euclidean Algorithm

def extended_gcd(a, b):
    \"\"\"
    Returns (gcd, x, y) such that ax + by = gcd.
    This implements Bezout's Identity.
    \"\"\"
    if a == 0:
        return b, 0, 1
    gcd, x1, y1 = extended_gcd(b % a, a)
    x = y1 - (b // a) * x1
    y = x1
    return gcd, x, y

# Finding the modular inverse of a mod n
def mod_inverse(a, n):
    gcd, x, y = extended_gcd(a, n)
    if gcd != 1:
        raise ValueError("Modular inverse does not exist")
    else:
        return x % n

Advanced Topics: The Riemann Zeta Function

The distribution of primes is inextricably linked to the Riemann Zeta Function: The Riemann Hypothesis, which states all non-trivial zeros of have real part , remains the most significant unsolved problem in mathematics, directly impacting our refined understanding of prime distribution.

Exercise

Conceptual Check

Using Fermat's Little Theorem, what is 3^10 mod 11?