Exercises 12.6 Additional Exercises: Primality and Factoring
In the RSA cryptosystem it is important to be able to find large prime numbers easily. Also, this cryptosystem is not secure if we can factor a composite number that is the product of two large primes. The solutions to both of these problems are quite easy. To find out if a number1.
A better algorithm for factoring odd positive integers is Fermat's factorization algorithm.
-
Let
be an odd composite number. Prove that can be written as the difference of two perfect squares:Consequently, a positive odd integer can be factored exactly when we can find integers
and such that Write a program to implement the following factorization algorithm based on the observation in part (a). The expression
ceiling(sqrt(n))
means the smallest integer greater than or equal to the square root of Write another program to do factorization using trial division and compare the speed of the two algorithms. Which algorithm is faster and why?
x := ceiling(sqrt(n))
y := 1
1 : while x^2 - y^2 > n do
y := y + 1
if x^2 - y^2 < n then
x := x + 1
y := 1
goto 1
else if x^2 - y^2 = 0 then
a := x - y
b := x + y
write n = a * b
2. Primality Testing.
Recall Fermat's Little Theorem 11.26 from Section 11.2. Let
However,
We say that an odd composite number
Which of the following numbers are primes and which are pseudoprimes?
601
3.
Let
4.
Write a program to determine all primes less than
There exist composite numbers that are pseudoprimes for all bases to which they are relatively prime. These numbers are called Carmichael numbers. The first Carmichael number is