 
Summary: 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
nif any m
divides n then it is composite, otherwise it is prime. This test was known since the time of the ancient
