# Prime number

In mathematics, a **prime number** (or **prime**) is a natural number greater than one whose only positive divisors are one and itself. Or for short: A prime number is a natural number with exactly two natural divisors. A natural number that is greater than one and is not a prime is called a composite number. The numbers zero and one are neither prime nor composite. The property of being a prime is called *primality*. Prime numbers are of fundamental importance in number theory.

The sequence of prime numbers begins

- 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, ...

This is sequence A000040 in OEIS; see list of prime numbers for the first 500 primes. The set of all prime numbers is sometimes denoted by ℙ, a blackboard bold **P**. As 2 is the only even prime number, the term *odd prime* is used to refer to all prime numbers except 2.

In the context of ring theory, a branch of abstract algebra, the term "prime element" has a specific meaning. Here, a ring element *a* is defined to be prime if whenever *a* divides *bc* for ring elements *b* and *c*, then *a* divides at least one of *b* or *c*. With this meaning, the additive inverse of any prime number is also prime. In other words, when considering the set of integers ℤ (**Z**) as a ring, −7 is a prime element. However, even among mathematicians, the term "prime number" generally means a positive prime integer.

## Contents

- 1 Representing natural numbers as products of primes
- 2 How many prime numbers are there?
- 3 Finding prime numbers
- 4 Some properties of primes
- 5 Open questions
- 6 The largest known prime
- 7 Applications
- 8 Primality tests
- 9 Some special types of primes
- 10 Prime gaps
- 11 Formulae yielding prime numbers
- 12 Generalizations
- 13 Quotes
- 14 See also
- 15 References
- 16 External links

## Representing natural numbers as products of primes

The fundamental theorem of arithmetic states that every positive integer can be written as a product of primes in a unique way, i.e. unique except for the order. Primes are thus the "basic building blocks" of the natural numbers (The proof of this is below). For example, we can write

and any other such factorization of 23244 will be identical, except for the order of the factors. See prime factorization algorithm for details for how to do this in practice, for larger numbers.

The importance of this theorem is one of the reasons for the exclusion of 1 from the set of prime numbers. If 1 were admitted as a prime, the precise statement of the theorem would require additional qualifications.

Proof: Every positive integer greater than 1 has a prime divisor.

We prove this through contradiction; we assume that there exists a number greater than one that has no prime divisors. Then, as the set of positive integers greater than one with no prime divisors is not an empty set, the well-ordering property tells us that there is a least one positive integer n greater than 1 with no prime divisors. Since n has no prime divisors and n divides n, we see that n is not prime. Hence we can write n=ab with 1<a<n and 1<b<n. Having assumed n to be the lowest integer in the set, a must have a prime divisor as a<n. But any divisor of a is also a divisor of n, so n must have a prime divisor, contradicting our statement that n has no prime divisors. Therefore we can conclude that every positive integer greater than one has a prime divisor.

## How many prime numbers are there?

There are infinitely many prime numbers. The oldest known proof for this statement is given by the Greek mathematician Euclid in his *Elements* (Book IX, Proposition 20). Euclid states the result as "there are more than any given [finite] number of primes", and his proof is essentially the following:

- Suppose you have a finite number of primes. Call this number m. Multiply all m primes together and add one (see Euclid number). The resulting number is not divisible by any of the finite set of primes, because dividing by any of these would give a remainder of one. And one is not divisible by any primes. Therefore it must either be prime itself, or be divisible by some other prime that was not included in the finite set. Either way, there must be at least m+1 primes. But this argument applies no matter what m is; it applies to m+1, too. So there are more primes than any given finite number.

Lemma: For any natural number A which is greater than 1, there exists a prime divisor for A.

- We can use proof by contradiction. Assume that there is a set of numbers that do not have prime divisors. We'll call this set K. By the well-ordering principle, there exist a minimal element k. k doesn't equal 1 because we convention above it. k also cannot be prime because it would otherwise have a prime divisor, namely itself. Therefore k must be composite. By definition a composite number is a non-prime number with at least one positive factor other than 1 and itself. Thus k can be written as k=ab. a and b are both less than k (a and b are positive integers that divide into k). Since k is the smallest value for which the theorem fails, then a and b must have prime divisors. And since k=ab, then k must have a prime divisor. Thus a contradiction occurs, and for any natural number A which is greater than 1, there exists a prime divisor for A.

This previous argument explains why the product of m primes + 1 must be divisible by some prime not in the finite set of primes.

Other mathematicians have given their own proofs. One of those (due to Euler) shows that the sum of the reciprocals of all prime numbers diverges to infinity. Kummer's is particularly elegant and Furstenberg provides one using general topology.

Even though the total number of primes is infinite, one could still ask "approximately how many primes are there below 100,000" or "How likely is a random 100-digit number to be prime?" Questions like these are answered by the prime number theorem.

## Finding prime numbers

The Sieve of Eratosthenes is a simple way and the Sieve of Atkin a fast way to compute the list of all prime numbers up to a given limit.

In practice though, one usually wants to check if a given number is prime, rather than generate a list of primes. Further, it is often satisfactory to know the answer with a high probability. It is possible to quickly check whether a given large number (say, up to a few thousand digits) is prime using probabilistic primality tests. These typically pick a random number called a "witness" and check some formula involving the witness and the potential prime *N*. After several iterations, they declare *N* to be "definitely composite" or "probably prime". These tests are not perfect. For a given test, there may be some composite numbers that will be declared "probably prime" no matter what witness is chosen. Such numbers are called pseudoprimes for that test.

A new deterministic algorithm which finds whether a given number *N* is prime where the time required is a polynomial function of the number of digits of *N* (i.e. of the logarithm of *N*) has recently been described.

## Some properties of primes

- If
*p*is a prime number and*p*divides a product*ab*of integers, then*p*divides*a*or*p*divides*b*. This proposition was proved by Euclid and is known as*Euclid's lemma*. It is used in some proofs of the uniqueness of prime factorizations. - The ring
**Z**/*n***Z**(see modular arithmetic) is a field if and only if*n*is a prime. Put another way:*n*is prime if and only if φ(*n*) =*n*− 1. - If
*p*is prime and*a*is any integer, then*a*^{p}−*a*is divisible by*p*(Fermat's little theorem). - If
*p*is a prime number other than 2 and 5, 1/p is always a recurring decimal, with a period of p-1 or a divisor of p-1. This can be deduced directly from Fermat's little theorem. 1/p expressed likewise in base q (i.e. other than base 10) has similar effect, provided that p is not a prime factor of q. The Wiki page on recurring decimal shows some of the interesting properties. - An integer
*p*> 1 is prime if and only if the factorial (*p*− 1)! + 1 is divisible by*p*(Wilson's theorem). Conversely, an integer*n*> 4 is composite if and only if (*n*− 1)! is divisible by*n*. - If
*n*is a positive integer greater than 1, then there is always a prime number*p*with*n*<*p*< 2*n*(Bertrand's postulate). - Adding the reciprocals of all primes together results in a divergent infinite series (proof). More precisely, if
*S*(*x*) denotes the sum of the reciprocals of all prime numbers*p*with*p*≤*x*, then*S*(*x*) = Θ(ln ln*x*) for*x*→ ∞ (see Big O notation). - For each prime number
*p*> 2, there exists a natural number*n*such that*p*= 4*n*± 1. - For each prime number
*p*> 3, there exists a natural number*n*such that*p*= 6*n*± 1. - In every arithmetic progression
*a*,*a*+*q*,*a*+ 2*q*,*a*+ 3*q*,... where the positive integers*a*and*q*≥ 1 are coprime, there are infinitely many primes (Dirichlet's theorem). - The characteristic of every field is either zero or a prime number.
- If
*G*is a finite group and*p*^{n}is the highest power of the prime*p*which divides the order of*G*, then*G*has a subgroup of order*p*^{n}. (Sylow theorems) - If
*p*is prime and*G*is a group with*p*^{n}elements, then*G*contains an element of order*p*. - The prime number theorem says that the proportion of primes less than
*x*is asymptotic to 1/ln*x*(in other words, as*x*gets very large, the likelihood that a number less than*x*is prime is inversely proportional to the number of digits in*x*).

## Open questions

There are many open questions about prime numbers. The most significant of these is the Riemann hypothesis, which essentially says that the primes are as regularly distributed as possible. From a physical viewpoint, it roughly states that the irregularity in the distribution of primes only comes from random noise. From a mathematical viewpoint, it roughly states that the asymptotic distribution of primes (about 1/ log *x* of number less than *x* are primes, the prime number theorem) also holds for much shorter intervals of length about the square root of *x* (for intervals near *x*). This hypothesis is generally believed to be correct, in particular, the simplest assumption is that primes should have no significant irregularities without good reason.

Other famous conjectures have a much greater chance of being true (in a formal sense, they follow from simple heuristic probabilistic arguments) with the lack of a solution more of a reflection of lack of good technical tools (so theoretical physicists would just regard them as being true):

- Goldbach's conjecture: Can every even integer greater than 2 be written as a sum of two primes?
- Twin prime conjecture: A
*twin prime*is a pair of primes with difference 2, such as 11 and 13. Are there infinitely many twin primes? - Does the Fibonacci sequence contain an infinite number of primes?
- Are there infinitely many Mersenne primes and Fermat primes? The expected answers are
*yes*, resp.*no*. - Are there infinitely many primes of the form
*n*^{2}+ 1? - Legendre's conjecture: Is there always a prime number between
*n*^{2}and (*n*+ 1)^{2}for every*n*? - Cramer's conjecture that , the largest gap between consecutive primes, among all primes less than
*x*, is asymptotic to . This conjecture clearly implies the previous one, but its status is a little more unsure. - Brocard's conjecture: Are there always at least four primes between the squares of successive primes > 2?

## The largest known prime

The largest known prime, as of September 2005, is
2^{25964951} − 1 (this number is 7,816,230 digits long); it is the 42nd known Mersenne prime. M_{25964951} was found on February 18, 2005 by Martin Nowak, a member of a collaborative effort known as GIMPS.

The next largest known prime is 2^{24036583} − 1 (this number is 7,235,733 digits long); it is the 41st known Mersenne prime.
M_{24036583} was found on May 15, 2004 by Josh Findley (member of GIMPS) and it was announced in late May 2004.

The third largest known prime is 2^{20996011} − 1 (this number is 6,320,430 digits long); it is the 40th known Mersenne prime.
M_{20996011} was found on November 17, 2003 by Michael Shafer (and GIMPS) and announced in early December 2003.

Historically, the largest known prime has almost always been a Mersenne prime since the dawn of electronic computers, because there exists a particularly fast primality test for numbers of this form, the Lucas-Lehmer test for Mersenne primes.

The largest known prime that is *not* a Mersenne prime is 27653 × 2^{9167433} + 1 (2,759,677 digits). This is also the fifth largest known prime of any form. It was found by the Seventeen or Bust project and it brings them one step closer to solving the Sierpinski problem.

Some of the largest primes not known to have any particular form (that is, no simple formula such as that of Mersenne primes) have been found by taking a piece of semi-random binary data, converting it to a number `n`, multiplying it by 256^{k} for some positive integer `k`, and searching for possible primes within the interval [256^{k}*n* + 1, 256^{k}(*n* + 1) − 1].

In fact, as a publicity stunt against the Digital Millennium Copyright Act and other WIPO Copyright Treaty implementations, some people have applied this to various forms of DeCSS code, creating the set of illegal prime numbers. Such numbers, when converted to binary and executed as a computer program, perform acts encumbered by applicable law in one or more jurisdictions.

## Applications

Extremely large prime numbers (that is, greater than 10^{100}) are used in several public key cryptography algorithms. Primes are also used for hash tables and pseudorandom number generators.

## Primality tests

*Main article primality test*

A primality test algorithm is an algorithm which tests a number for primality, i.e. whether the number is a prime number.

- AKS primality test
- Fermat primality test
- Lucas-Lehmer test
- Lucas-Lehmer primality test
- Solovay-Strassen primality test
- Miller-Rabin primality test

A probable prime is an integer which, by virtue of having passed a certain test, is considered to be probably prime. Probable primes which are in fact composite (such as Carmichael numbers) are called pseudoprimes.

## Some special types of primes

A prime *p* is called *primorial* or *prime-factorial* if it has the form *p* = Π(*n*) ± 1 for some number *n*, where Π(*n*) stands for the product 2 · 3 · 5 · 7 · 11 · ... of all the primes ≤ n. A prime is called *factorial* if it is of the form *n*! ± 1. The first factorial primes are:

The largest known primorial prime is Π(24029) + 1, found by Caldwell in 1993. The largest known factorial prime is 3610! − 1 [Caldwell, 1993]. It is not known if there are infinitely many primorial or factorial primes.

Primes of the form 2^{n} − 1 are known as Mersenne primes, while primes of the form are known as Fermat primes. Prime numbers *p* where 2*p* + 1 is also prime are known as Sophie Germain primes. Other special types of prime numbers include Wieferich primes, Wilson primes, Wall-Sun-Sun primes, Wolstenholme primes, unique primes, Newman-Shanks-Williams primes (NSW primes), Smarandache-Wellin primes, Wagstaff primes and supersingular primes.

The base-ten digit sequence of a prime can be a palindrome, as in the prime 10^{31512} + 9700079 · 10^{15753} + 1.

## Prime gaps

Let *p*_{n} denote the *n*-th prime number (i.e. *p*_{1} = 2, *p*_{2} = 3, etc.). The *gap* *g*_{n} between the consecutive primes *p*_{n} and *p*_{n + 1} is the number of (composite) numbers between them, i.e.

*g*_{n}=*p*_{n + 1}−*p*_{n}− 1.

(Slightly different definitions are sometimes used.) We have *g*_{1} = 0, *g*_{2} = *g*_{3} = 1, and *g*_{4} = 3. The sequence {*g*_{n}} of prime gaps has been extensively studied.

For any *N*, the sequence

- (
*N*+ 1)! + 2, (*N*+ 1)! + 3, ..., (*N*+ 1)! +*N*+ 1

is a sequence of *N* consecutive composite integers. Therefore, there exist gaps between primes which are arbitrarily large, i.e. for any natural number *N*, there is an integer *n* with *g*_{n} > *N*. (Choose *n* so that *p*_{n} is the greatest prime number less than (*N* + 1)! + 2.) On the other hand, the gaps get arbitrarily small in proportion to the primes: the quotient (*g*_{n}/*p*_{n}) approaches zero as *n* approaches infinity.

We say that *g*_{n} is a *maximal gap* if *g*_{m} < *g*_{n} for all *m* < *n*. The largest known maximal gap is 1131, found by T. Nicely and B. Nyman in 1999. It is the 64th smallest maximal gap, and it occurs after the prime 1693182318746371.

The largest prime gap with identified gap ends known as of 1 January 2005 has a length of 2254930 [1].

Note that the Twin Prime Conjecture simply asserts that *g*_{n} = 1 for infinitely many integers *n*.

## Formulae yielding prime numbers

*Main article formula for primes*

There is no formula for primes which is more efficient at finding primes than the methods mentioned above under "Finding prime numbers". Those which do exist have little practical value.

The curious polynomial *f*(*n*) = *n*^{2} − *n* + 41 yields primes for *n* = 0,..., 40, but *f*(41) is composite. It has been proved that there is no polynomial which only yields prime numbers in this fashion.

There is a set of Diophantine equations in 9 variables and one parameter with the following property: the parameter is prime if and only if the resulting system of equations has a solution over the natural numbers. This can be used to obtain a single formula with the property that all its *positive* values are prime.

Another formula is based on Wilson's theorem mentioned above, and generates the number two many times and all other primes exactly once. There are other similar formulae which also produce primes.

## Generalizations

The concept of prime number is so important that it has been generalized in different ways in various branches of mathematics.

### Prime elements in rings

One can define prime elements and irreducible elements in any integral domain. For the ring **Z** of integers, the set of prime elements equals the set of irreducible elements; it's {...−11, −7, −5, −3, −2, 2, 3, 5, 7, 11, ...}.

As an example, we consider the Gaussian integers **Z**[*i*], that is, complex numbers of the form *a* + *bi* with *a* and *b* in **Z**. This is an integral domain, and its prime elements are the Gaussian primes. Note that 2 is *not* a Gaussian prime, because it factors into the product of the two Gaussian primes (1 + *i*) and (1 − *i*). The element 3, however, remains prime in the Gaussian integers. In general, rational primes (i.e. prime elements in the ring **Z** of integers) of the form 4*k* + 3 are Gaussian primes, whereas rational primes of the form 4*k* + 1 are not.

### Prime ideals

In ring theory, one generally replaces the notion of number with that of ideal. *Prime ideals* are an important tool and object of study in commutative algebra, algebraic number theory and algebraic geometry.
The prime ideals of the ring of integers are the ideals (0), (2), (3), (5), (7), (11), ...

A central problem in algebraic number theory is how a prime ideal factors when it is *lifted* to an extension field. For example, in the Gaussian integer example above, (2) *ramifies* into a prime power (1 + *i* and 1 − *i* generate the same prime ideal), prime ideals of the form (4*k* + 3) are *inert* (remain prime), and prime ideals of the form (4*k* + 1) *split* (are the product of 2 distinct prime ideals).

### Primes in valuation theory

In class field theory yet another generalization is used. Given an arbitrary field *K*, one considers valuations on *K*, certain functions from *K* to the real numbers **R**. Every such valuation yields a topology on *K*, and two valuations are called *equivalent* if they yield the same topology. A *prime of K* (sometimes called a *place of K*) is an equivalence class of valuations. With this definition, the primes of the field **Q** of rational numbers are represented by the standard absolute value function (known as the "infinite prime") as well as by the *p*-adic valuations on **Q**, for every prime number *p*.

## Quotes

- "Mathematicians have tried in vain to this day to discover some order in the sequence of prime numbers, and we have reason to believe that it is a mystery into which the human mind will never penetrate." —
*Leonhard Euler*

- "God may not play dice with the universe, but something strange is going on with the prime numbers." —
*Paul Erdős*

## See also

- prime polynomial
- Prime power
- Sphenic number
- Highly composite number
- Primorial
- Jørgen Pedersen Gram
- Logarithmic integral function

## References

- Karl Sabbagh,
*The Riemann Hypothesis: The Greatest Unsolved Problem in Mathematics*. Farrar, Straus and Giroux; 340 pages - John Derbyshire,
*Prime Obsession: Bernhard Riemann and the Greatest Unsolved Problem in Mathematics*. Joseph Henry Press; 448 pages - Marcus du Sautoy,
*The Music of the Primes: Searching to Solve the Greatest Mystery in Mathematics*. HarperCollins; 352 pages - H. Riesel,
*Prime Numbers and Computer Methods for Factorization*, 2nd ed., Birkhäuser 1994.

## External links

- Prime curios at the prime pages
- The prime pages -- http://www.utm.edu/research/primes/
- MacTutor history of prime numbers
- Online Prime Number calculator
- The "PRIMES is in P" FAQ
- The first 20,000 primes (through 224737) at Wikisource
- List of largest known probable primes
- The prime puzzles
- The Prime Project generates a new prime number every time the page is loaded
- An English translation of Euclid's proof that there are infinitely many primes
- Primes from WIMS is an online prime generator.
- Prime Factorization Worksheet generates new questions every time the page is loaded
- Prime Spiral pattern
- 12 digit primes Known 12-digit prime factors of Googolplex - 1
- An Introduction to Analytic Number Theory, by Ilan Vardi and Cyril Banderier
- Factorizer Windows software to find prime numbers and pairs of prime numbers less than 2,147,483,646.
- PHP Prime Number Caculator PHP Prime Number Caculator script. Goes until PHP overloads :)

Template:Link FAaf:Priemgetal ang:Frumtæl bg:Просто число be:Просты лік ca:Nombre primer cs:Prvočíslo da:Primtal de:Primzahl et:Algarv el:Πρώτος αριθμός es:Número primo eo:Primo eu:Zenbaki lehen fr:Nombre premier ko:소수 (수론) id:Bilangan prima is:Frumtala it:Numero primo he:מספר ראשוני la:Numerus primus lt:Pirminiai skaičiai hu:Prímszámok nl:Priemgetal ja:素数 no:Primtall pl:Liczby pierwsze pt:Número primo ru:Простое число scn:Nummuru primu sl:Praštevilo sr:Прост број sv:Primtal th:จำนวนเฉพาะ tr:Asal sayılar uk:Просте число zh:素数