formula for primes
   HOME

TheInfoList



OR:

In
number theory Number theory (or arithmetic or higher arithmetic in older usage) is a branch of pure mathematics devoted primarily to the study of the integers and integer-valued functions. German mathematician Carl Friedrich Gauss (1777–1855) said, "Ma ...
, a formula for primes is a
formula In science, a formula is a concise way of expressing information symbolically, as in a mathematical formula or a ''chemical formula''. The informal use of the term ''formula'' in science refers to the general construct of a relationship betwe ...
generating the
prime number A prime number (or a prime) is a natural number greater than 1 that is not a Product (mathematics), product of two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime ...
s, exactly and without exception. No such formula which is efficiently computable is known. A number of constraints are known, showing what such a "formula" can and cannot be.


Formulas based on Wilson's theorem

A simple formula is :f(n) = \left\lfloor \frac \right\rfloor (n-1) + 2 for positive
integer An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the languag ...
n, where \lfloor\ \rfloor is the
floor function In mathematics and computer science, the floor function is the function that takes as input a real number , and gives as output the greatest integer less than or equal to , denoted or . Similarly, the ceiling function maps to the least int ...
, which rounds down to the nearest integer. By
Wilson's theorem In algebra and number theory, Wilson's theorem states that a natural number ''n'' > 1 is a prime number if and only if the product of all the positive integers less than ''n'' is one less than a multiple of ''n''. That is (using the notations of m ...
, n+1 is prime if and only if n! \equiv n \pmod. Thus, when n+1 is prime, the first factor in the product becomes one, and the formula produces the prime number n+1. But when n+1 is not prime, the first factor becomes zero and the formula produces the prime number 2. This formula is not an efficient way to generate prime numbers because evaluating n! \bmod (n+1) requires about n-1 multiplications and reductions modulo n+1. In 1964, Willans gave the formula :p_n = 1 + \sum_^ \left\lfloor \left(\frac\right)^ \right\rfloor for the nth prime number p_n. This formula is also not efficient. In addition to the appearance of (j-1)!, it computes p_n by adding up p_n copies of 1; for example, p_5 = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + \dots + 0 = 11.


Formula based on a system of Diophantine equations

Because the set of primes is a
computably enumerable set In computability theory, a set ''S'' of natural numbers is called computably enumerable (c.e.), recursively enumerable (r.e.), semidecidable, partially decidable, listable, provable or Turing-recognizable if: *There is an algorithm such that the ...
, by
Matiyasevich's theorem In mathematics, a Diophantine equation is an equation of the form ''P''(''x''1, ..., ''x'j'', ''y''1, ..., ''y'k'') = 0 (usually abbreviated ''P''(', ') = 0) where ''P''(', ') is a polynomial with integer coefficients, where ''x''1, ..., ' ...
, it can be obtained from a system of
Diophantine equation In mathematics, a Diophantine equation is an equation, typically a polynomial equation in two or more unknowns with integer coefficients, such that the only solutions of interest are the integer ones. A linear Diophantine equation equates to a ...
s. found an explicit set of 14 Diophantine equations in 26 variables, such that a given number ''k'' + 2 is prime
if and only if In logic and related fields such as mathematics and philosophy, "if and only if" (shortened as "iff") is a biconditional logical connective between statements, where either both statements are true or both are false. The connective is bic ...
that system has a solution in
natural number In mathematics, the natural numbers are those numbers used for counting (as in "there are ''six'' coins on the table") and ordering (as in "this is the ''third'' largest city in the country"). Numbers used for counting are called '' cardinal ...
s: : \alpha_0= wz + h + j - q = 0 : \alpha_1 = (gk + 2g + k + 1)(h + j) + h - z = 0 : \alpha_2= 16(k + 1)^3(k + 2)(n + 1)^2 + 1 - f^2 = 0 : \alpha_3= 2n + p + q + z - e = 0 : \alpha_4= e^3(e + 2)(a + 1)^2 + 1 - o^2 = 0 : \alpha_5=(a^2 - 1)y^2 + 1 - x^2 = 0 : \alpha_6= 16r^2y^4(a^2 - 1) + 1 - u^2 = 0 : \alpha_7= n + \ell + v - y = 0 : \alpha_8= (a^2 - 1)\ell^2 + 1 - m^2 = 0 : \alpha_9= ai + k + 1 - \ell - i = 0 : \alpha_= ((a + u^2(u^2 - a))^2 - 1)(n + 4dy)^2 + 1 - (x + cu)^2 = 0 : \alpha_= p + \ell(a - n - 1) + b(2an + 2a - n^2 - 2n - 2) - m= 0 : \alpha_= q + y(a - p - 1) + s(2ap + 2a - p^2 - 2p - 2) - x = 0 :\alpha_= z + p\ell(a - p) + t(2ap - p^2 - 1) - pm = 0 The 14 equations ''α''0, …, ''α''13 can be used to produce a prime-generating polynomial inequality in 26 variables: : (k+2)(1-\alpha_0^2-\alpha_1^2-\cdots-\alpha_^2) > 0 i.e.: : \begin & (k+2) (1 - \\ pt& z + h + j - q2 - \\ pt& gk + 2g + k + 1)(h + j) + h - z2 - \\ pt& 6(k + 1)^3(k + 2)(n + 1)^2 + 1 - f^22 - \\ pt& n + p + q + z - e2 - \\ pt& ^3(e + 2)(a + 1)^2 + 1 - o^22 - \\ pt& a^2 - 1)y^2 + 1 - x^22 - \\ pt& 6r^2y^4(a^2 - 1) + 1 - u^22 - \\ pt& + \ell + v - y2 - \\ pt& a^2 - 1)\ell^2 + 1 - m^22 - \\ pt& i + k + 1 - \ell - i2 - \\ pt& (a + u^2(u^2 - a))^2 - 1)(n + 4dy)^2 + 1 - (x + cu)^22 - \\ pt& + \ell(a - n - 1) + b(2an + 2a - n^2 - 2n - 2) - m2 - \\ pt& + y(a - p - 1) + s(2ap + 2a - p^2 - 2p - 2) - x2 - \\ pt& + p\ell(a - p) + t(2ap - p^2 - 1) - pm2) \\ pt& > 0 \end is a polynomial inequality in 26 variables, and the set of prime numbers is identical to the set of positive values taken on by the left-hand side as the variables ''a'', ''b'', …, ''z'' range over the nonnegative integers. A general theorem of Matiyasevich says that if a set is defined by a system of Diophantine equations, it can also be defined by a system of Diophantine equations in only 9 variables. Hence, there is a prime-generating polynomial as above with only 10 variables. However, its degree is large (in the order of 1045). On the other hand, there also exists such a set of equations of degree only 4, but in 58 variables.


Mills' formula

The first such formula known was established by , who proved that there exists a
real number In mathematics, a real number is a number that can be used to measure a ''continuous'' one-dimensional quantity such as a distance, duration or temperature. Here, ''continuous'' means that values can have arbitrarily small variations. Every ...
''A'' such that, if :d_n = A^ then :\left \lfloor d_n \right \rfloor = \left \lfloor A^ \right \rfloor is a prime number for all positive integers ''n''. If the
Riemann hypothesis In mathematics, the Riemann hypothesis is the conjecture that the Riemann zeta function has its zeros only at the negative even integers and complex numbers with real part . Many consider it to be the most important unsolved problem in p ...
is true, then the smallest such ''A'' has a value of around 1.3063778838630806904686144926... and is known as
Mills' constant In number theory, Mills' constant is defined as the smallest positive real number ''A'' such that the floor function of the double exponential function : \lfloor A^ \rfloor is a prime number for all natural numbers ''n''. This constant is ...
. This value gives rise to the primes \left \lfloor d_1 \right \rfloor = 2, \left \lfloor d_2 \right \rfloor = 11, \left \lfloor d_3 \right \rfloor = 1361, ... . Very little is known about the constant ''A'' (not even whether it is
rational Rationality is the quality of being guided by or based on reasons. In this regard, a person acts rationally if they have a good reason for what they do or a belief is rational if it is based on strong evidence. This quality can apply to an abi ...
). This formula has no practical value, because there is no known way of calculating the constant without finding primes in the first place. Note that there is nothing special about the
floor function In mathematics and computer science, the floor function is the function that takes as input a real number , and gives as output the greatest integer less than or equal to , denoted or . Similarly, the ceiling function maps to the least int ...
in the formula. Tóth proved that there also exists a constant B such that : \lceil B^ \rceil is also prime-representing for r>2.106\ldots . In the case r=3, the value of the constant B begins with 1.24055470525201424067... The first few primes generated are: :2, 7, 337, 38272739, 56062005704198360319209, 176199995814327287356671209104585864397055039072110696028654438846269, \ldots ''Without'' assuming the Riemann hypothesis, Elsholtz developed several prime-representing functions similar to those of Mills. For example, if A \approx 1.00536773279814724017, then \left\lfloor A^ \right\rfloor is prime for all positive integers n. Similarly, if A \approx 3.8249998073439146171615551375, then \left\lfloor A^ \right\rfloor is prime for all positive integers n.


Wright's formula

Another prime-generating formula similar to Mills' comes from a theorem of E. M. Wright. He proved that there exists a real number ''α'' such that, if :g_0 = \alpha and :g_ = 2^ for n \ge 0, then :\left \lfloor g_n \right \rfloor = \left \lfloor 2^ \right \rfloor is prime for all n \ge 1. Wright gives the first seven decimal places of such a constant: \alpha = 1.9287800. This value gives rise to the primes \left \lfloor g_1 \right \rfloor = \left \lfloor 2^ \right \rfloor = 3 , \left \lfloor g_2 \right \rfloor = 13 , and \left \lfloor g_3 \right \rfloor = 16381 . \left \lfloor g_4 \right \rfloor is
even Even may refer to: General * Even (given name), a Norwegian male personal name * Even (surname) * Even (people), an ethnic group from Siberia and Russian Far East **Even language, a language spoken by the Evens * Odd and Even, a solitaire game wh ...
, and so is not prime. However, with \alpha = 1.9287800 + 8.2843 \cdot 10^, \left \lfloor g_1 \right \rfloor, \left \lfloor g_2 \right \rfloor, and \left \lfloor g_3 \right \rfloor are unchanged, while \left \lfloor g_4 \right \rfloor is a prime with 4932 digits. This
sequence In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called ''elements'', or ''terms''). The number of elements (possibly infinite) is called ...
of primes cannot be extended beyond \left \lfloor g_4 \right \rfloor without knowing more digits of \alpha. Like Mills' formula, and for the same reasons, Wright's formula cannot be used to find primes.


A function that represents all primes

Given the constant f_1 = 2.920050977316\ldots , for n \ge 2, define the sequence where \left\lfloor\ \right\rfloor is the
floor function In mathematics and computer science, the floor function is the function that takes as input a real number , and gives as output the greatest integer less than or equal to , denoted or . Similarly, the ceiling function maps to the least int ...
. Then for n \ge 1, \left\lfloor f_ \right\rfloor equals the nth prime: \left\lfloor f_1 \right\rfloor = 2, \left\lfloor f_2 \right\rfloor = 3, \left\lfloor f_3 \right\rfloor = 5, etc. The initial constant f_1 = 2.920050977316 given in the article is precise enough for equation () to generate the primes through 37, the 12th prime. The ''exact'' value of f_1 that generates ''all'' primes is given by the rapidly-converging series : f_1 = \sum_^\infty \frac = \frac + \frac + \frac + \frac + \cdots, where p_n is the nth prime, and P_n is the product of all primes less than p_n. The more digits of f_1 that we know, the more primes equation () will generate. For example, we can use 25 terms in the series, using the 25 primes less than 100, to calculate the following more precise approximation: : f_1 \simeq 2.920050977316134712092562917112019. This has enough digits for equation () to yield again the 25 primes less than 100. As with Mills' formula and Wright's formula above, in order to generate a longer list of primes, we need to start by knowing more digits of the initial constant, f_1, which in this case requires a longer list of primes in its calculation.


Plouffe's formulas

In 2018 Simon Plouffe
conjecture In mathematics, a conjecture is a conclusion or a proposition that is proffered on a tentative basis without proof. Some conjectures, such as the Riemann hypothesis (still a conjecture) or Fermat's Last Theorem (a conjecture until proven in ...
d a set of formulas for primes. Similarly to the formula of Mills, they are of the form :\left\ where \ is the function rounding to the nearest integer. For example, with a_0\approx 43.80468771580293481 and r=5/4, this gives 113, 367, 1607, 10177, 102217... Using a_0=10^+961+\varepsilon and r=1.01 with \varepsilon a certain number between 0 and one half, Plouffe found that he could generate a sequence of 50 probable primes (with high probability of being prime). Presumably there exists an ε such that this formula will give an infinite sequence of actual prime numbers. The number of digits starts at 501 and increases by about 1% each time.


Prime formulas and polynomial functions

It is known that no non- constant
polynomial In mathematics, a polynomial is an expression consisting of indeterminates (also called variables) and coefficients, that involves only the operations of addition, subtraction, multiplication, and positive-integer powers of variables. An exampl ...
function ''P''(''n'') with integer coefficients exists that evaluates to a prime number for all integers ''n''. The proof is as follows: suppose that such a polynomial existed. Then ''P''(1) would evaluate to a prime ''p'', so P(1) \equiv 0 \pmod p. But for any integer ''k'', P(1+kp) \equiv 0 \pmod p also, so P(1+kp) cannot also be prime (as it would be divisible by ''p'') unless it were ''p'' itself. But the only way P(1+kp) = P(1) = p for all ''k'' is if the polynomial function is constant. The same reasoning shows an even stronger result: no non-constant polynomial function ''P''(''n'') exists that evaluates to a prime number for
almost all In mathematics, the term "almost all" means "all but a negligible amount". More precisely, if X is a set, "almost all elements of X" means "all elements of X but those in a negligible subset of X". The meaning of "negligible" depends on the mathema ...
integers ''n''.
Euler Leonhard Euler ( , ; 15 April 170718 September 1783) was a Swiss mathematician, physicist, astronomer, geographer, logician and engineer who founded the studies of graph theory and topology and made pioneering and influential discoveries in ...
first noticed (in 1772) that the
quadratic polynomial In mathematics, a quadratic polynomial is a polynomial of degree two in one or more variables. A quadratic function is the polynomial function defined by a quadratic polynomial. Before 20th century, the distinction was unclear between a polynomial ...
:P(n) = n^2 + n + 41 is prime for the 40 integers ''n'' = 0, 1, 2, ..., 39, with corresponding primes 41, 43, 47, 53, 61, 71, ..., 1601. The differences between the terms are 2, 4, 6, 8, 10... For ''n'' = 40, it produces a
square number In mathematics, a square number or perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, 9 is a square number, since it equals and can be written as . The u ...
, 1681, which is equal to 41 × 41, the smallest
composite number A composite number is a positive integer that can be formed by multiplying two smaller positive integers. Equivalently, it is a positive integer that has at least one divisor In mathematics, a divisor of an integer n, also called a factor ...
for this formula for ''n'' ≥ 0. If 41 divides ''n'', it divides ''P''(''n'') too. Furthermore, since ''P''(''n'') can be written as ''n''(''n'' + 1) + 41, if 41 divides ''n'' + 1 instead, it also divides ''P''(''n''). The phenomenon is related to the Ulam spiral, which is also implicitly quadratic, and the class number; this polynomial is related to the
Heegner number In number theory, a Heegner number (as termed by Conway and Guy) is a square-free positive integer ''d'' such that the imaginary quadratic field \Q\left sqrt\right/math> has class number 1. Equivalently, its ring of integers has unique factori ...
163=4\cdot 41-1. There are analogous polynomials for p=2, 3, 5, 11 \text 17 (the
lucky numbers of Euler Euler's "lucky" numbers are positive integers ''n'' such that for all integers ''k'' with , the polynomial produces a prime number. When ''k'' is equal to ''n'', the value cannot be prime since is divisible by ''n''. Since the polynomial can b ...
), corresponding to other Heegner numbers. Given a positive integer ''S'', there may be infinitely many ''c'' such that the expression ''n''2 + ''n'' + ''c'' is always coprime to ''S''. The integer ''c'' may be negative, in which case there is a delay before primes are produced. It is known, based on
Dirichlet's theorem on arithmetic progressions In number theory, Dirichlet's theorem, also called the Dirichlet prime number theorem, states that for any two positive coprime integers ''a'' and ''d'', there are infinitely many primes of the form ''a'' + ''nd'', where ''n'' is ...
, that linear polynomial functions L(n) = an + b produce infinitely many primes as long as ''a'' and ''b'' are
relatively prime In mathematics, two integers and are coprime, relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1. Consequently, any prime number that divides does not divide , and vice versa. This is equivale ...
(though no such function will assume prime values for all values of ''n''). Moreover, the
Green–Tao theorem In number theory, the Green–Tao theorem, proved by Ben Green and Terence Tao in 2004, states that the sequence of prime numbers contains arbitrarily long arithmetic progressions. In other words, for every natural number ''k'', there exist arith ...
says that for any ''k'' there exists a pair of ''a'' and ''b'', with the property that L(n) = an+b is prime for any ''n'' from 0 through ''k'' − 1. However, the best known result of such type is for ''k'' = 27: :224584605939537911 + 18135696597948930n is prime for all ''n'' from 0 through 26. It is not even known whether there exists a
univariate polynomial In mathematics, a polynomial is an expression consisting of indeterminates (also called variables) and coefficients, that involves only the operations of addition, subtraction, multiplication, and positive-integer powers of variables. An ex ...
of degree at least 2, that assumes an infinite number of values that are prime; see
Bunyakovsky conjecture The Bunyakovsky conjecture (or Bouniakowsky conjecture) gives a criterion for a polynomial f(x) in one variable with integer coefficients to give infinitely many prime values in the sequencef(1), f(2), f(3),\ldots. It was stated in 1857 by the ...
.


Possible formula using a recurrence relation

Another prime generator is defined by the
recurrence relation In mathematics, a recurrence relation is an equation according to which the nth term of a sequence of numbers is equal to some combination of the previous terms. Often, only k previous terms of the sequence appear in the equation, for a parameter ...
: a_n = a_ + \gcd(n,a_), \quad a_1 = 7, where gcd(''x'', ''y'') denotes the
greatest common divisor In mathematics, the greatest common divisor (GCD) of two or more integers, which are not all zero, is the largest positive integer that divides each of the integers. For two integers ''x'', ''y'', the greatest common divisor of ''x'' and ''y'' is ...
of ''x'' and ''y''. The sequence of differences ''a''''n''+1 − ''an'' starts with 1, 1, 1, 5, 3, 1, 1, 1, 1, 11, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 23, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 47, 3, 1, 5, 3, ... . proved that this sequence contains only ones and prime numbers. However, it does not contain all the prime numbers, since the terms gcd(''n'' + 1, ''an'') are always
odd Odd means unpaired, occasional, strange or unusual, or a person who is viewed as eccentric. Odd may also refer to: Acronym * ODD (Text Encoding Initiative) ("One Document Does it all"), an abstracted literate-programming format for describing X ...
and so never equal to 2. 587 is the smallest prime (other than 2) not appearing in the first 10,000 outcomes that are different from 1. Nevertheless, in the same paper it was conjectured to contain all odd primes, even though it is rather inefficient.. Note that there is a trivial program that enumerates all and only the prime numbers, as well as more efficient ones, so such recurrence relations are more a matter of curiosity than of any practical use.


See also

*
Prime number theorem In mathematics, the prime number theorem (PNT) describes the asymptotic distribution of the prime numbers among the positive integers. It formalizes the intuitive idea that primes become less common as they become larger by precisely quantifying t ...


References


Further reading

*. *A Venugopalan. ''Formula for primes, twinprimes, number of primes and number of twinprimes''. Proceedings of the Indian Academy of Sciences—Mathematical Sciences, Vol. 92, No 1, September 1983
pp. 49–52errata


External links

* {{Prime number classes Prime numbers