3

*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

Joebloggs
  • 160

2 Answers2

4

No.

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

J. W. Tanner
  • 63,683
  • 4
  • 43
  • 88
3

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$$

lulu
  • 76,951
  • I suspected it didn't, but I hoped it would, because it would be a useful generating function for numbers that could be used as test inputs for a factorisation algorithm. Seeing that for the first few n values at least, it produced only primes or semi-primes, and these are obviously the hardest instances such an algorithm would encounter, but without having to go to the trouble of generating them in a more contrived way, from a list of primes for example. Obviously, if this had held for larger values, it would be a more organic, and simpler way of producing test number cases for an algorithm. – Joebloggs Oct 29 '19 at 11:34
  • 1
    There's really no great way to generate primes or "near" primes. If you are comfortable with factoring algorithms, you can guess numbers in the region you want and test them. That generally works pretty well. Or you can just work off of lists, as you suggest. – lulu Oct 29 '19 at 12:36
  • 1
    check if $x=2ab+a+b$ where both $a,b$ are not expressible further in that form.... then $2x+1$ is a semiprime. See sieve of sundaram. –  Oct 29 '19 at 12:42
  • Maybe I was being a bit disingenuous with seemingly plucking that example out of thin air. Was just messing around as usual, and something interesting popped up, with a very basic underlying principle. – Joebloggs Oct 29 '19 at 12:51
  • Another concrete example, with the same characteristics would be the following: – Joebloggs Oct 29 '19 at 12:52
  • $n^2 + 101n + 197$ – Joebloggs Oct 29 '19 at 12:52
  • They all conform to the general equation: $n^2 + (p + 4)n + (2p + 3)$ where p is any prime number. – Joebloggs Oct 29 '19 at 12:54
  • 1
    Worth noting: it is easy to prove that no polynomial with integer coefficients (and degree at least $1$) can take only prime or semi prime values. Start with the standard argument to show that any such polynomial has a composite value, say $p(n)=m$. Then for each integer $k$ we have $m,|,p(n+km)$ and $m$ can't divide any semi prime larger than itself. – lulu Oct 29 '19 at 12:57
  • oh and yes you can extend the algorithm above, pick one of $a,b$ to be of the form using $c,d$, with the other, and $c,d$ not of the form you get distinct odd 3 almost primes. –  Oct 29 '19 at 19:56
  • May be so, but I think if you plug a prime big enough into this, then it seems (from examples) that the first however many (x) numbers generated will all be of this form. There shouldn't be any shortage of prime numbers; by all accounts they go on forever. – Joebloggs Oct 31 '19 at 14:01