DOWNLOAD Mathematica Notebook EXPLORE THIS TOPIC IN the MathWorld Classroom Contribute to this entry

A prime number (or prime integer, often simply called a "prime" for short) is apositive integer p>1that has no positive integer约数other than 1 andpitself. More concisely, a prime numberpis apositive integerexactly onepositive divisor other than 1, meaning it is a number that cannot be factored. For example, the only divisors of 13 are 1 and 13, making 13 a prime number, while the number 24 has divisors 1, 2, 3, 4, 6, 8, 12, and 24 (corresponding to the factorization24=2^3·3), making 24a prime number.Positive integersother than 1 which are not prime are calledcomposite numbers

While the term "prime number" commonly refers to prime positive integers, other types of primes are also defined, such as theGaussian primes

The number 1 is a special case which is considered neither prime nor composite (Wells 1986, p. 31). Although the number 1 used to be considered a prime (Goldbach 1742; Lehmer 1909, 1914; Hardy and Wright 1979, p. 11; Gardner 1984, pp. 86-87; Sloane and Plouffe 1995, p. 33; Hardy 1999, p. 46), it requires special treatment in so many definitions and applications involving primes greater than or equal to 2 that it is usually placed into a class of its own. A good reason not to call 1 a prime number is that if 1 were prime, then the statement of thefundamental theorem of arithmeticwould have to be modified since "inexactly oneway" would be false because anyn=n·1In other words,unique factorizationinto a product of primes would fail if the primes included 1. A slightly less illuminating but mathematically correct reason is noted by Tietze (1965, p. 2), who states "Why is the number 1 made an exception? This is a problem that schoolboys often argue about, but since it is a question of definition, it is not arguable." As more simply noted by Derbyshire (2004, p. 33), "2 pays its way [as a prime] on balance; 1 doesn't."

With 1 excluded, the smallest prime is therefore 2. However, since 2 is the onlyeven prime(which, ironically, in some sense makes it the "oddest" prime), it is also somewhat special, and the set of all primes excluding 2 is therefore called the "odd primes." Note also that while 2 is considered a prime today, at one time it was not (Tietze 1965, p. 18; Tropfke 1921, p. 96).

这个Nth prime number is commonly denotedp_n, sop_1=2p_2=3, and so on, and may be computed in theWolfram Language作为Prime[N].

The first few primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, ... (OEISA000040; Hardy and Wright 1979, p. 3). mnemonicfor remembering the first seven primes is, "In the early morning, astronomers spiritualized nonmathematicians" (G. L. Honaker, Jr., pers. comm., Aug. 4, 2005). In the novelThe Curious Incident of the Dog in the Night-Time(Haddon 2003), the protagonist Christopher amusingly numbers the chapters using the prime numbers instead of the (much) more traditional positive integers. In the Season 1 episode "Prime Suspect" (2005) of the television crime dramaNUMB3RS, math genius Charlie Eppes realized that character Ethan's daughter has been kidnapped because he is close to solving theRiemann hypothesis, which allegedly would allow the perpetrators to break essentially all internet security by factoring large numbers.

The numbers of decimal digits inp_(10^n)n=0, 1, ... is given by 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, ... (OEISA099260).

这个配置of primes is sometimes denotedP, represented in theWolfram Language作为Primes


The first few primes are illustrated above as a sequence of binary bits.

Euler commented "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 mind will never penetrate" (Havil 2003, p. 163). In a 1975 lecture, D. Zagier commented "There are two facts about the distribution of prime numbers of which I hope to convince you so overwhelmingly that they will be permanently engraved in your hearts. The first is that, despite their simple definition and role as the building blocks of the natural numbers, the prime numbers grow like weeds among the natural numbers, seeming to obey no other law than that of chance, and nobody can predict where the next one will sprout. The second fact is even more astonishing, for it states just the opposite: that the prime numbers exhibit stunning regularity, that there are laws governing their behavior, and that they obey these laws with almost military precision" (Havil 2003, p. 171).

这个10^nth prime forn=0, 1, ... is given by 2, 29, 541, 7919, 104729, 1299709, 15485863, 179424673, 2038074743, ... (OEISA006988; Grahamet al.1990, p. 111).

Large primes (Caldwell) include the largeMersenne primesFerrier's prime, and the一百五十二万一千五百六十一-digit counterexample5359·2^(5054502)+1showing that 5359 is not aSierpiński number of the second kind(Helm and Norris). The largest known prime as of December 2018 is the梅森素数 2^(82589933)-1, which has a whopping二千四百八十六万二千零四十八decimal digits.

Prime numbers can be generated by sieving processes (such as thesieve of Eratosthenes), andlucky numbers, which are also generated by sieving, appear to share some interesting asymptotic properties with the primes. Prime numbers satisfy many strange and wonderful properties. Although there exist explicitprime formulas(i.e., formulas which either generate primes for all values or else theNth prime as a function ofN), they are contrived to such an extent that they are of little practical value.

这个Dirichlet generating functionof the characteristic function of the prime numbersp_nis given by

sum_(n=1)^(infty)([n in {p_k}_(k=1)^infty])/(n^s)=sum_(n=1)^(infty)1/(p_n^s)

哪里P(s)is theprime zeta function[S]is anIverson bracket

The function that gives the number of primes less than or equal to a numberNis denotedpi(n)and is called theprime counting functionThe theorem giving an asymptotic form forpi(n)is called theprime number theoremSimilarly, the numbers of primes of the formak+bless than or equal to a numberNis denotedpi_(a,b)(n)and is called themodular prime counting function

pi(n)p_nare inverse functions, so


for all positive integers and


iff Nis a prime number.

Manyprime factorization algorithmshave been devised for determining theprime factorsof a giveninteger, a process known as factorization or prime factorization. They vary quite a bit in sophistication and complexity. It is非常difficult to build a general-purpose algorithm for this computationally "hard" problem, so any additional information which is known about the number in question or its factors can often be used to save a large amount of time. It should be emphasized that although no efficient algorithms are known for factoring arbitrary integers, it has not been证明that no such algorithm exists. It is therefore conceivable that a suitably clever person could devise a general method of factoring which would render the vast majority of encryption schemes in current widespread use, including those used by banks and governments, easily breakable.

Because of their importance in encryption algorithms such asRSA encryption, prime numbers can be important commercial commodities. In fact, R. Schlafly (1994) has obtained U.S. Patent五百三十七万三千五百六十on the following two primes (expressed inhexadecimalnotation):



这个fundamental theorem of arithmeticstates that anypositive integercan be represented inexactly oneway as a产品of primes.Euclid's second theoremdemonstrated that there are an infinite number of primes. However, it is not known if there are an infinite number of primesof the form n^2+1(Hardy and Wright 1979, p. 19; Ribenboim 1996, pp. 206-208), whether there are an无限的number oftwin primes(the孪生素数猜想), or if a prime can always be found betweenn^2(n+1)^2(Hardy and Wright 1979, p. 415; Ribenboim 1996, pp. 397-398). The latter two of these are two ofLandau's problems

The simplest method of finding factors is so-called "direct search factorization" (a.k.a.trial division). In this method, all possible factors are systematically tested using trial division to see if they actuallythe given number. It is practical only for very small numbers. More general (and complicated) methods include theelliptic curve factorization method数域筛法factorization method.

It has been proven that the set of prime numbers is aDiophantine set(Ribenboim 1991, pp. 106-107).

With the exception of 2 and 3, all primes are of the formp=6n+/-1, i.e.,p=1,5 (mod 6)(Bungus 1599, p. 399, quoted in Peano 1908, p. 59; Wells 1986, p. 68). Naninteger >=2Nis primeiff这个同余式

 (n-1; k)=(-1)^k (mod n)

holds fork=0, 1, ...,n-1(Deutsch 1996), where(n; k)is abinomial coefficientIn addition, an integerNis primeiff


The first few compositeNfor whichn|[phi(n)+sigma(n)]n=312, 560, 588, 1400, 23760, ... (OEISA011774; Guy 1997), with a total of 18 such numbers less than2×10^7

Chen (1979) showed that forxsufficiently large, there always exists a number with at least two prime factors betweenx-x^alphaxalpha>=0.477...(Le Lionnais 1983, p. 26; Guy 2004, p. 34). In practice, this relation seems to hold for allx>2521

Primes consisting of consecutivedigits(counting 0 as coming after 9) include 2, 3, 5, 7, 23, 67, 89, 4567, 78901, ... (OEISA006510). Primes consisting of digits that are themselves primes include 23, 37, 53, 73, 223, 227, 233, 257, 277, 337, 353, 373, 523, 557, ... (OEISA019546), which is one of theSmarandache sequences

Because a prime numberphas only the琐碎的factors 1 andp, in hisThe Road Ahead, Bill Gates accidentally referred to a trivial operation when he stated "Because both the system's privacy and the security of digital money depend on encryption, a breakthrough in mathematics or computer science that defeats the cryptographic system could be a disaster. The obvious mathematical breakthrough would be the development of an easy way tofactor large prime numbers[emphasis added]" (Gates 1995, p. 265).

Wolfram Web Resources

Mathematica »

The #1 tool for creating Demonstrations and anything technical.

Wolfram|Alpha »

Explore anything with the first computational knowledge engine.

Wolfram Demonstrations Project »

Explore thousands of free applications across science, mathematics, engineering, technology, business, art, finance, social sciences, and more.

Computerbasedmath.org »

Join the initiative for modernizing math education.

Online Integral Calculator »

Solve integrals with Wolfram|Alpha.

Step-by-step Solutions »

Walk through homework problems step-by-step from beginning to end. Hints help you try the next step on your own.

Wolfram Problem Generator »

Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.

Wolfram Education Portal »

Collection of teaching and learning tools built by Wolfram education experts: dynamic textbook, lesson plans, widgets, interactive Demonstrations, and more.

Wolfram Language »

Knowledge-based programming for everyone.