TITLE: Determining the next Twin Prime?
QUESTION [5 upvotes]: 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?

REPLY [2 votes]: Since
$$\sigma_0(n−1) + \sigma_0(n+1)−4 \ge 0$$
with equality exactly when $n-1$ and $n+1$ are both primes, what about a generating function like
\begin{align}
 \frac{4}{x-1} + \sum_{k=1}^\infty \frac{x^{k-1}(x^2\!+1)}{1-x^k}
 &= - 3 - 2x - x^2\! + x^3\! + 3x^5\! + 4x^7\! + x^8\! + 4x^{9}\! + x^{10}\! \\
  &\hspace{3em} + 6x^{11}\! + 6x^{13}\! + 2x^{14}\! + 5x^{15}\! + 2x^{16}\! + 7x^{17}\! + 8x^{19}\! + \cdots,
\end{align}
where the set of missing exponents, $\{4,6,12,18,30,42,\dots\}$, is the set of twin prime separators? Does that suit your needs?