Does the following function only generate primes and semi-prime* composites for all values of n?

199 Views Asked by At

*semi-prime, i.e. two distinct prime factors, but these could be raised to any powers.

Generating function:

$n^2 + 21n + 37$

First few values are:

enter image description here

2

There are 2 best solutions below

1
On

No.

$201^2+21\times201+37=17\times37\times71$

10
On

In this case, there is no difficulty producing a counterexample:

Taking $n=133$ yields $20519 = 17^2×71$.

More broadly, it is easy to prove that no non-constant polynomial with integer coefficients can take only prime and semi prime values.

Pf: It is well known, see this for instance, that no such $p(n)$ can take only prime values. Thus we can solve $p(n_0)=m$ for some composite $m$. But then $m\,|\,p(n_0+mk)$ for all $k\in \mathbb Z$ and $m$ can't divide any semiprime other than $\pm m$.

Still, the expression does seem to yield a lot of primes/semi primes for small $n$. Why is that?

The point is that there can't be "small" prime divisors. It is easy to see that none of $\{2,3,5,7,11,13\}$ can divide a value of your polynomial, so $17$ is the smallest possible prime factor. After $17$, it is easy to see that none of $\{19,23,29\}$ can divide any values either. If you stick to small $n$, it's no surprise then that you don't get a lot of factors.

To be precise, the least integer which is neither a prime nor a semi prime and which is not divisible by any prime $<17$ is $17^3$, and your polynomial doesn't get that big until $n\approx 60$. Thus we know immediately that at least the first $60$ values have the form you want.

We should expect that the phenomenon you describe ceases to dominate as $n$ gets large. Indeed, just looking at the values between $n=10000$ and $n=10004$ gives

$$5527\times 18131, 853\times 117503, 53\times 71\times 26641, 43\times 653\times 3571, 107\times 109\times 8599$$