Download presentation
Presentation is loading. Please wait.
1
Divisibility and Primes
ICS 6D Sandy Irani
2
Evenly Divides x evenly divides y if y =m·x for some integer m
Denoted: x|y y is an integer multiple (or just “multiple”) of x x is a factor of y
3
Primes and Composites A number p is prime if
p is an integer and p > 1 The only (positive) factors of p are 1 and p. If n > 1 is not prime, it is composite n has a positive factor other than 1 or n.
4
Fundamental Theorem of Arithmetic
Every integer n > 1 can be expressed as a product of primes. Prime factorization is unique up to ordering. Prime factorization of n usually written in non-decreasing order: 124 =
5
Fundamental Theorem of Arithmetic
Prime factorization of 360:
6
Exponential Notation for Prime Factorization
Write each distinct prime in the prime factorization in increasing order. The multiplicity of a prime (# of times it appears) is written in the exponent. 124 = 360 =
7
Prime Factorization and Divisibility
If you have the prime factorization for x and y, can easily determine if x divides y: Example: does 90 divide 1260? 1260 = 22 · 32 · 5 · 7 90 = 2 · 32 · 5
8
Prime Factorization and Divisibility
1260 = 22 · 32 · 5 · 7 40 = 23· 5 22 = 2 · 11
9
LCM and GCD Two positive integers, x and y.
The least common multiple of x and y, lcm(x,y), is the smallest integer that is a multiple of x and a multiple of y. The greatest common divisor of x and y, gcd(x, y) is the largest integer that divides both x and y. x and y are relatively prime if gcd(x, y) = 1
10
Prime Factorization and LCM
If you have the prime factorization for x and y, can easily determine if lcm(x, y): 44 = 22 · = 2 · 32 · 5
11
Prime Factorization and GDC
If you have the prime factorization for x and y, can easily determine if gcd(x, y): 1320 = 23 ·3 · 5 · = 22 · 32 · 5
12
Factoring: Brute-force algorithm
Input: integer N > 1 Output: (x,y) such that x > 1, y > 1 and xy = N or “Prime” if N is prime For x = 2 to N-1 If x evenly divides N Return(x, N/x) Return(“Prime”)
13
Factoring: slightly better algorithm
Input: integer N > 1 Output: (x,y) such that x > 1, y > 1 and xy = N or “Prime” if N is prime For x = 2 to N-1 𝑁 If x evenly divides N Return(x, N/x) Return(“Prime”) If N is composite than it as at least one factor that is at most 𝑵
14
Factoring: slightly better algorithm
Input: integer N > 1 Output: (x,y) such that x > 1, y > 1 and xy = N or “Prime” if N is prime For x = 2 to N-1 𝑁 If x evenly divides N Return(x, N/x) Return(“Prime”) If N has 200 digits 𝑵 has 100 digits If inner loop takes .1 ns Algorithm take 3 x 1082 years Time proportional to the value of N, not the number of digits
15
Factoring and Primality Testing
Input: integer N > 1 Output: If N is prime: “Prime” If N is composite: x > 1, y > 1, xy = N Primality Testing Input: integer N > 1 Output: If N is prime: “Prime” If N is composite: “Composite” Hard: no known algorithm that Runs in time (# digits)d Easy: can be solved in time (# digits)2 (probabilistic)
16
Finding Prime Numbers “Find a 200-digit prime number” How to do this?
Repeat: Pick a random 200 digit number N Apply primality test to N If N is prime, return(N) If N is composite, continue. The number of trials until success depends on the density of prime numbers among all 200 digit numbers
17
Density of primes: a first step
Theorem: there are an infinite number of prime numbers. Euclid ~300 B.C.
18
The Prime Number Theorem
Theorem: let π(x) be the number of prime numbers in the range [2,…,x], then lim 𝑥→∞ 𝜋(𝑥) 𝑥/( ln 𝑥) = 1 𝜋(𝑥) 𝑥 ln(𝑥)
19
The Prime Number Theorem
Theorem: let π(x) be the number of prime numbers in the range [2,…,x], then lim 𝑥→∞ 𝜋(𝑥) 𝑥/( ln 𝑥) = 1 Interpretation: A randomly chosen number in the range 2,..,x is prime with probability ~ 1 𝑙𝑛(𝑥) To get a 200 digit prime number, we need the density of primes in the range from to ln(x) ~ 2.3·(# digits in x)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.