Number Theory
Explore the properties of integers: divisibility, prime numbers, and modular arithmetic. These concepts form the foundation of cryptography and computer security.
- Understand divisibility and its properties
- Perform modular arithmetic operations
- Apply the Euclidean algorithm to find GCD
- Understand prime numbers and factorization
- Find modular multiplicative inverses
- Apply Bézout's identity
1. Divisibility
Let and be integers with . We say divides , written , if there exists an integer such that .
We also say is a factor or divisor of , and is a multiple of .
Let be integers:
- If and , then
- If , then for any integer
- If and , then (transitivity)
For any integers and , there exist unique integers (quotient) and (remainder) such that:
2. Modular Arithmetic
Let be a positive integer. We say is congruent to modulo , written , if .
Equivalently, and have the same remainder when divided by .
If and , then:
- for any positive integer
Calculate:
Solution: Find the pattern of powers of 7 mod 10:
The cycle repeats every 4. Since :
3. GCD and Euclidean Algorithm
The greatest common divisor of integers and , denoted , is the largest positive integer that divides both and .
If , we say and are coprime (relatively prime).
To find where :
Euclidean(a, b):
while b ≠ 0:
r = a mod b
a = b
b = r
return a
Correctness: Based on the fact that
Find:
Therefore,
For any integers and with , there exist integers and such that:
These coefficients can be found using the Extended Euclidean Algorithm.
4. Prime Numbers
An integer is prime if its only positive divisors are 1 and .
An integer that is not prime is called composite.
Every integer can be expressed as a product of primes uniquely, up to the order of factors.
There are infinitely many prime numbers.
Suppose there are finitely many primes: .
Consider .
N is not divisible by any (remainder is 1).
So either N is prime, or N has a prime factor not in our list.
Both cases contradict our assumption. ∎
5. Modular Multiplicative Inverse
The multiplicative inverse of modulo is an integer such that:
We write .
has a multiplicative inverse modulo if and only if .
Find:
We need such that .
Using Extended Euclidean Algorithm or testing:
Therefore,
Practice Quiz
Frequently Asked Questions
Why is number theory important in computer science?
Number theory is the foundation of:
- Cryptography: RSA, Diffie-Hellman rely on modular arithmetic and primes
- Hash functions: Often use modular arithmetic
- Random number generation: Based on number-theoretic properties
- Error-correcting codes: Use finite field arithmetic
How do I quickly find GCD?
Use the Euclidean algorithm:
- Divide larger by smaller, get remainder
- Replace larger with smaller, smaller with remainder
- Repeat until remainder is 0
- GCD is the last non-zero remainder
What's the difference between mod and remainder?
In mathematics, is always in range .
Some programming languages may return negative values for negative dividends. Mathematical modulo is always non-negative.
When does a modular inverse exist?
exists if and only if (a and n are coprime).
If n is prime, every non-zero element has an inverse (this makes a field).
How is the Fundamental Theorem of Arithmetic used?
The unique prime factorization is used to:
- Find GCD and LCM from prime factorizations
- Count divisors of a number
- Solve Diophantine equations
- Prove theorems about integers