





























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Primality testing, a fundamental problem in number theory. It covers the definition of prime numbers, the naive primality test, and fermat's primality test. The document also discusses the time complexity of these tests and their limitations. It is suitable for university students studying mathematics or computer science.
Typology: Slides
1 / 37
This page cannot be seen from the preview
Don't miss anything!






























Definition: A positive integer n is prime iff its only divisors are 1 and n.
Examples: 7 is a prime. 111 is not a prime.
Is 225593397919 a prime?
Is 2^229-91 a prime? (2^229-91 = 862718293348820473429344482784628181556388621521298319395315527974821 )
n is a prime iff its only divisors are 1 and n
(define (divides? a b) (= (remainder b a) 0)) (define (smallest-divisor n) (define (find-divisor n i) (cond ((> i (sqrt n)) n) ((divides? i n) i) (else (find-divisor n (+ i 1))))) (find-divisor n 2))
If n is a 800 digit number, that’s is also very bad. Absolutely infeasible.
2013/4/23 10
Fermat’s theorem: Every prime will always pass the test. Definition: A Carmichael number, is a number such that
Error probability smaller than the chance the hardware is faulty.
Suppose we do the test t=100 times.
function Fermat (n) a := random integer between 1 and n- if (expomod (a,n-1,n) = 1 then return true // n might be prime else return false // n is not prime