Determining the next Twin Prime?

3k Views Asked by At

A really simple I question I guess. Is there an algorithm or method such that given an integer $N$ there is a way to determine the next twin prime pair greater than $N$?

If yes, then could you please explain it?

4

There are 4 best solutions below

1
On

Nope. As far as I know there's no algorithm beyond sieveing for primes past $N$ until you find a twin pair.

5
On

Let $x=N+1$. If $x$ and $x+2$ are prime, you're done. If not, let $x=x+1$ and repeat. :-P

8
On

It isn't even known that there is always a twin prime pair greater than $N$ (so strictly speaking, there isn't an algorithm that is known to work).

8
On

I wouldn't be so quick to dismiss timidpueo's “algorithm” (although it could easily be made faster by replacing $N+1$ by $N+6$, among other tricks). Conjecturally, the average spacing between twin primes is $O(\log^2 N)$ and the worst-case spacing is $O(\log^3 N)$. So in practice, this is a polynomial time “algorithm” (even though it is not guaranteed to terminate, hence the quotes).