PRIMES is in P
Manindra Agrawal
Neeraj Kayal
Nitin Saxena
*
Department of Computer Science & Engineering
Indian Institute of Technology Kanpur
Kanpur208016, INDIA
Email:
{
manindra,kayaln,nitinsa
}
@iitk.ac.in
Abstract
We present an unconditional deterministic polynomialtime algorithm that determines whether
an input number is prime or composite.
1
Introduction
Prime numbers are of fundamental importance in mathematics in general, and number theory in par
ticular. So it is of great interest to study different properties of prime numbers. Of special interest are
those properties that allow one to efficiently determine if a number is prime. Such efficient tests are also
useful in practice: a number of cryptographic protocols need large prime numbers.
Let PRIMES denote the set of all prime numbers. The definition of prime numbers already gives a
way of determining if a number
n
is in PRIMES: try dividing
n
by every number
m
≤
√
n
—if any
m
divides
n
then it is composite otherwise prime. This test was already known since the time of ancient
Greeks—it is a specialization of the
Sieve of Eratosthenes
(ca. 240 BC) that generates all primes less
then
n
. The test, however, is inefficient: it takes Ω(
√
n
) steps to determine if
n
is prime. An efficient
test should need only a polynomial (in the size of the input =
log
n
) number of steps. A property that
almost
gives an efficient test is Fermat’s Little Theorem: for any prime number
p
, and any number
a
not
divisible by
p
,
a
p

1
= 1 (mod
p
). Given an
a
and
n
it can be efficiently checked if
a
n

1
= 1 (mod
n
)
using repeated squaring to compute (
n

1)
th
power of
a
. However, it is not a correct test since many
composites
n
also satisfy it for some
a
’s (
all
a
’s in case of
Carmichael
numbers [Car10]). Nevertheless,
Fermat’s Little Theorem became the basis for many efficient primality tests.
Since the beginning of complexity theory in 1960s—when the notions of problem complexity were
formalized and various complexity classes were defined—this problem (referred as
primality testing
prob
lem) has been investigated intensively. It is trivial to see that the problem is in the class coNP: if
n
is not prime it has an easily verifiable short certificate, viz., a nontrivial factor of
n
.
In 1974, Pratt
observed that the problem is in the class NP too [Pra75] (thus putting it in NP
∩
coNP).
In 1975, Miller [Mil76] used a property based on Fermat’s Little Theorem to obtain a deterministic
polynomialtime algorithm for primality testing assuming
Extended Riemann Hypothesis (ERH)
. Within
a year, his test was modified by Rabin [Rab80] to yield an unconditional but randomized polynomial
time algorithm. Independently, Solovay and Strassen [SS77] obtained, in 1974, a different randomized
polynomialtime algorithm using the property that for a prime
n
,
(
a
n
)
=
a
n

1
2
(mod
n
) for every
a
(
(
)
is
the Jacobi symbol). Their algorithm can also be made deterministic under ERH. Since then, a number of
randomized polynomialtime algorithms have been proposed for primality testing based on many different
properties.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '04
 CHUNG
 Computer Science, Prime number

Click to edit the document details