13

It seems like there is no polynomial with finite variables known, which could generate all prime numbers, by integer assignments. Is there a proof that such polynomial can not exist and does anyone have one in his/her stack?

Bill Dubuque
  • 285,713
Hooman
  • 3,827
  • You might be interested in: http://mathworld.wolfram.com/Prime-GeneratingPolynomial.html – Amzoti Sep 10 '12 at 22:28
  • 5
    It is confusing to ask one question in the title and a different question in the body (in the body you don't specify what the coefficients should be). The body of the question should be self-contained (I usually don't go back up to the title to see if there's any extra information there and I'm sure I'm not the only one). – Qiaochu Yuan Sep 11 '12 at 03:34
  • There is a polynomial $f(p,x_1,\ldots,x_n)$ with coefficients in $\mathbb Z$ such that $p$ is a positive prime number if an only if $\exists x_1\in\mathbb Z\ \cdots\ \exists x_n\in\mathbb Z\ f(p,x_1,\ldots,x_n)=0$. If I recall correctly it can be done with $\deg f=4$ and $n=14$. ${}\qquad{}$ – Michael Hardy Aug 09 '14 at 12:44
  • Related: https://math.stackexchange.com/questions/59846/proof-of-no-prime-representing-polynomial-in-2-variables – Watson Oct 24 '16 at 07:45
  • Please review my latest thoughts on this: made answer below. Basically using the same topology Furstenberg uses in infinitude of primes, we can show this. Except we use that all polynomials are automatically continuous functions, so their inverse image maps should take open balls (cosets $a\Bbb{Z} + b$) to open balls, but there's an obvious hangup (contradiction), but only if we restrict and say that $f(x)$ must take on only prime numbers. So I've shown that it's impossible for any polynomial to take on any subset $\text{im} f = S \subset \Bbb{P}$ such that $|S| \gt 2$. – EffingLoveMath Aug 15 '25 at 11:59

4 Answers4

20

In fact there does not even exist a non-constant polynomial $f$ (I assume you want integer coefficients) which only takes prime values with integer inputs. It suffices to prove this for polynomials in one variable. By the hypothesis that $f$ is non-constant, it takes arbitrarily large values, so without loss of generality $|f(0)| > 1$; in particular, $f(0)$ is divisible by some prime $p$. Then $f(kp)$ is always divisible by $p$, hence cannot be prime for sufficiently large $k$.

However, remarkably there do exist polynomials in more than one variable all of whose positive values are prime.

Qiaochu Yuan
  • 478,279
  • 1
    The question asked for rational coefficients, and the argument fails in this case. For example, $f(x)=(x^2+x+4)/2$ is integer-valued with rational coefficients, and $f(0)=2$ is divisible by the prime, 2, but $f(2)=5$ is not divisible by 2. – Gerry Myerson Sep 11 '12 at 03:16
  • 3
    @Gerry: oh, I see; rational is specified in the title. That's confusing. In any case, rational coefficients is not a problem: just ensure in addition that $k$ is divisible by the least common denominator of the coefficients. In your example, $f(4)$ is divisible by $2$. – Qiaochu Yuan Sep 11 '12 at 03:33
  • @QiaochuYuan Please see my answer, I invoke "polynomials are continuous in Furstenberg topologies." – EffingLoveMath Aug 15 '25 at 11:39
  • Just to add: To generalize this to arbitrarily many variables $f$, let $g(x)=f(x,0,...,0)$ and apply the above argument to $g(x)$. – 19021605 Sep 18 '25 at 08:37
4

Consider a polynomial $P(n)$ with integer coefficients; also, assume that the constant term (coefficient of $n^{0}$), is $a_{0}$.

If $a_{0}\neq 1$, then, putting $n=c*a_{0}$, where c is a non-zero integer, shall yield a multiple of $a_{0}$.

In general, $P(cP(1)+1)$ shall always be divisible by $P(1)$. Hence, the given polynomial cannot generate only primes!!

0

Here, it is clear that by hand-picking values, it is clear that there is no all-prime generating polynomial. It is even possible to demonstrate that there are infinite composite values to the function as well.


First of all, we state that a polynomial with integer input, and integer coefficients will only give integer output. This is because any positive power (the exponent in the function) of an integer is also an integer, and an integer multiplied by an integer (coefficient) is also an integer.

We write a general polynomial function in the form: $$f(x)=a_mx^m+a_{m-1}x^{m-1}+\cdots+a_2x^2+a_1x^1+a_0x^0.$$ Note that it is allowed in this proof for individual values of $a$ to be $0$, even the $a_m$, but just that there must be at least one non-constant term!

Now, we let the arbitrary integer $n$ be of the form $ka_0$ where $k$ can be any integer. We substitute $x=ka_0$ into the polynomial form, which gives us: $$f(n)=f(ka_0)=a_m(ka_0)^m+a_{m-1}(ka_0)^{m-1}+\cdots+a_2(ka_0)^2+a_1(ka_0)^1+a_0(ka_0)^0.$$ Let's expand that: $$f(ka_0)=a_mk^ma_0^m+a_{m-1}k^{m-1}a_0^{m-1}+\cdots+a^2k^2a_0^2+a^1k^1a_0^1+a_0k^0a_0^0.$$ We notice that every term in the new expression has a factor of $a_0$! This means that $a_0$ is a factor of the value of the polynomial output.

Here, we notice that we defined $k$ as any arbitrary integer, so we can set it to any value we want. This gives us infinite outputs for the function as composite numbers, since $k$ can be any desired integer. $\square$

0

This is one I recently discovered.

Disclaimer. But this assumes that we're asking the same question about a polynomial that generates only prime numbers.

Proof. If you consider $f \in \Bbb{Q}[x]$ to be $f: \Bbb{Q} \to \Bbb{Q}$ as a function from/to topologies $(\Bbb{Z}, \tau)$ where $\tau$ is Furstenberg's topology on $\Bbb{Q}$, namely all $a + b\Bbb{Z}$ such that $b \neq 0$ and $a,b\in \Bbb{Q}$, then it is clear that $\Bbb{Q}$ is a topological ring (same as usual $\Bbb{Z}$), so that $+, \cdot, -$ are continuous operations. This means every polynomial $f \in \Bbb{Q}[x]$ is a continuous as an integer function. Now, suppose that $f$ were to generate a prime number $p$ only finitely many times. Then $A = f^{-1}(U_{p,0})$ where $U_{p,0} = p\Bbb{Z} + 0$ is an open ball, is such that $|A|$ is a finite set, which can't possibly be open in Furstenberg's topology since the open balls generating Furstenberg's topology are infinite sets. So unless a polynomial is constant, it cannot revisit a prime infinitely often. QED, we handled all the cases.


I would describe this as a proof by Furstenberg continuity argument.