MathIsimple
DM-07
Course 7

Number Theory

Explore the properties of integers: divisibility, prime numbers, and modular arithmetic. These concepts form the foundation of cryptography and computer security.

Learning Objectives
  • 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

Definition 7.1: Divisibility

Let aa and bb be integers with a0a \neq 0. We say aa divides bb, written aba \mid b, if there exists an integer kk such that b=akb = ak.

We also say aa is a factor or divisor of bb, and bb is a multiple of aa.

Theorem 7.1: Properties of Divisibility

Let a,b,ca, b, c be integers:

  • If aba \mid b and aca \mid c, then a(b+c)a \mid (b + c)
  • If aba \mid b, then abca \mid bc for any integer cc
  • If aba \mid b and bcb \mid c, then aca \mid c (transitivity)
Theorem 7.2: Division Algorithm

For any integers aa and d>0d > 0, there exist unique integers qq (quotient) and rr (remainder) such that:

a=dq+rwhere 0r<da = dq + r \quad \text{where } 0 \leq r < d

2. Modular Arithmetic

Definition 7.2: Congruence

Let nn be a positive integer. We say aa is congruent to bb modulo nn, written ab(modn)a \equiv b \pmod{n}, if n(ab)n \mid (a - b).

Equivalently, aa and bb have the same remainder when divided by nn.

Theorem 7.3: Properties of Congruence

If ab(modn)a \equiv b \pmod{n} and cd(modn)c \equiv d \pmod{n}, then:

  • a+cb+d(modn)a + c \equiv b + d \pmod{n}
  • acbd(modn)a - c \equiv b - d \pmod{n}
  • acbd(modn)ac \equiv bd \pmod{n}
  • akbk(modn)a^k \equiv b^k \pmod{n} for any positive integer kk
Example: Modular Arithmetic

Calculate: 7100mod107^{100} \mod 10

Solution: Find the pattern of powers of 7 mod 10:

  • 717(mod10)7^1 \equiv 7 \pmod{10}
  • 72499(mod10)7^2 \equiv 49 \equiv 9 \pmod{10}
  • 73633(mod10)7^3 \equiv 63 \equiv 3 \pmod{10}
  • 74211(mod10)7^4 \equiv 21 \equiv 1 \pmod{10}

The cycle repeats every 4. Since 100=4×25100 = 4 \times 25:

7100=(74)25125=1(mod10)7^{100} = (7^4)^{25} \equiv 1^{25} = 1 \pmod{10}

3. GCD and Euclidean Algorithm

Definition 7.3: Greatest Common Divisor

The greatest common divisor of integers aa and bb, denoted gcd(a,b)\gcd(a, b), is the largest positive integer that divides both aa and bb.

If gcd(a,b)=1\gcd(a, b) = 1, we say aa and bb are coprime (relatively prime).

Algorithm 7.1: Euclidean Algorithm

To find gcd(a,b)\gcd(a, b) where ab>0a \geq b > 0:

Euclidean(a, b):

while b ≠ 0:

r = a mod b

a = b

b = r

return a

Correctness: Based on the fact that gcd(a,b)=gcd(b,amodb)\gcd(a, b) = \gcd(b, a \mod b)

Example: Euclidean Algorithm

Find: gcd(252,105)\gcd(252, 105)

252=2×105+42252 = 2 \times 105 + 42

105=2×42+21105 = 2 \times 42 + 21

42=2×21+042 = 2 \times 21 + 0

Therefore, gcd(252,105)=21\gcd(252, 105) = 21

Theorem 7.4: Bézout's Identity

For any integers aa and bb with d=gcd(a,b)d = \gcd(a, b), there exist integers xx and yy such that:

ax+by=dax + by = d

These coefficients can be found using the Extended Euclidean Algorithm.

4. Prime Numbers

Definition 7.4: Prime Number

An integer p>1p > 1 is prime if its only positive divisors are 1 and pp.

An integer >1> 1 that is not prime is called composite.

Theorem 7.5: Fundamental Theorem of Arithmetic

Every integer >1> 1 can be expressed as a product of primes uniquely, up to the order of factors.

Theorem 7.6: Infinitude of Primes

There are infinitely many prime numbers.

Proof of Infinitely many primes (Euclid)

Suppose there are finitely many primes: p1,p2,,pnp_1, p_2, \ldots, p_n.

Consider N=p1p2pn+1N = p_1 p_2 \cdots p_n + 1.

N is not divisible by any pip_i (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

Definition 7.5: Multiplicative Inverse

The multiplicative inverse of aa modulo nn is an integer xx such that:

ax1(modn)ax \equiv 1 \pmod{n}

We write x=a1(modn)x = a^{-1} \pmod{n}.

Theorem 7.7: Existence of Inverse

aa has a multiplicative inverse modulo nn if and only if gcd(a,n)=1\gcd(a, n) = 1.

Example: Finding Modular Inverse

Find: 71(mod11)7^{-1} \pmod{11}

We need xx such that 7x1(mod11)7x \equiv 1 \pmod{11}.

Using Extended Euclidean Algorithm or testing:

7×8=56=5×11+11(mod11)7 \times 8 = 56 = 5 \times 11 + 1 \equiv 1 \pmod{11}

Therefore, 718(mod11)7^{-1} \equiv 8 \pmod{11}

Practice Quiz

Number Theory Quiz
10
Questions
0
Correct
0%
Accuracy
1
What is 17mod517 \mod 5?
Easy
Not attempted
2
What is gcd(48,18)\gcd(48, 18)?
Easy
Not attempted
3
If a3(mod7)a \equiv 3 \pmod{7} and b5(mod7)b \equiv 5 \pmod{7}, what is a+b(mod7)a + b \pmod{7}?
Medium
Not attempted
4
Which statement about primes is TRUE?
Easy
Not attempted
5
What is the multiplicative inverse of 3 modulo 7?
Medium
Not attempted
6
aba \mid b and aca \mid c implies:
Medium
Not attempted
7
The Fundamental Theorem of Arithmetic states that:
Medium
Not attempted
8
Bézout's identity states that for gcd(a,b)=d\gcd(a, b) = d:
Hard
Not attempted
9
Two integers are coprime if:
Easy
Not attempted
10
If gcd(a,n)=1\gcd(a, n) = 1, then aa has a multiplicative inverse modulo nn:
Hard
Not attempted

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:

  1. Divide larger by smaller, get remainder
  2. Replace larger with smaller, smaller with remainder
  3. Repeat until remainder is 0
  4. GCD is the last non-zero remainder

What's the difference between mod and remainder?

In mathematics, amodna \mod n is always in range [0,n1][0, n-1].

Some programming languages may return negative values for negative dividends. Mathematical modulo is always non-negative.

When does a modular inverse exist?

a1(modn)a^{-1} \pmod{n} exists if and only if gcd(a,n)=1\gcd(a, n) = 1 (a and n are coprime).

If n is prime, every non-zero element has an inverse (this makes Zp\mathbb{Z}_p 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