I have a pretty cool but probably impractical solution.
Consider this table of primes from $1$ to $110$:
$$
\begin{matrix}
2 & 3 & 5 & 7 & 11 \\
13 & 17 & 19 & 23 & 29 \\
31 & 37 & 41 & 43 & 47 \\
53 & 59 & 61 & 67 & 71 \\
73 & 79 & 83 & 89 & 97 \\
101 & 103 & 107 & 109 \\
\end{matrix}
$$
Notice the differences between all the primes. That table would look like this:
$$
\begin{matrix}
2 & 1 & 2 & 2 & 4 \\
2 & 4 & 2 & 4 & 6 \\
2 & 6 & 4 & 2 & 4 \\
6 & 6 & 2 & 6 & 4 \\
2 & 6 & 4 & 6 & 8 \\
4 & 2 & 4 & 2 \\
\end{matrix}
$$
Let's look at the combinations of 6 differences in order. They're ordered from left to right and up to down by value as if the sequences represented digits of a 6-digit number:
$$1,2,2,4,2,4 \ \ \ \ \ \ \ \ \ \ 2,1,2,2,4,2 \ \ \ \ \ \ \ \ \ \ 2,2,4,2,4,2$$
$$2,4,2,4,2,4 \ \ \ \ \ \ \ \ \ \ 2,4,2,4,6,2 \ \ \ \ \ \ \ \ \ \ 2,4,6,2,6,4$$
$$2,4,6,6,2,6 \ \ \ \ \ \ \ \ \ \ 2,6,4,2,4,6 \ \ \ \ \ \ \ \ \ \ 2,6,4,2,6,4$$
$$2,6,4,6,8,4 \ \ \ \ \ \ \ \ \ \ 4,2,4,2,4,6 \ \ \ \ \ \ \ \ \ \ 4,2,4,6,2,6$$
$$4,2,4,6,6,2 \ \ \ \ \ \ \ \ \ \ 4,2,6,4,6,8 \ \ \ \ \ \ \ \ \ \ 4,6,2,6,4,2$$
$$4,6,6,2,6,4 \ \ \ \ \ \ \ \ \ \ 4,6,8,4,2,4 \ \ \ \ \ \ \ \ \ \ 6,2,6,4,2,4$$
$$6,2,6,4,2,6 \ \ \ \ \ \ \ \ \ \ 6,4,2,4,6,6 \ \ \ \ \ \ \ \ \ \ 6,4,2,6,4,6$$
$$6,4,6,8,4,2 \ \ \ \ \ \ \ \ \ \ 6,6,2,6,4,2 \ \ \ \ \ \ \ \ \ \ 6,8,4,2,4,2$$
Notice that no two sequences are equal in the above list
Start out by iterating over values of $x$ in $[0,7]$ incrementally until you hit the first prime number. Let this value of $x$ be denoted as $k$.
The above step requires $8$ guesses in the worst case
You have to use new values for $x$ equal to $k + o$ where $o$ is an offset that starts at $1$ and changes based on what's prime and what's not.
If $k + 1$ is prime, you can stop. $n = 2$.
Else, try $k + 2$ and if that doesn't work, $k + 4$, then $k + 6$.
If for instance, $k + 4$ works, you would then try $k + 4 + 2$. If that's prime too, then continue with these combinations in the same manner:
$$4,2,4,2,4,6$$
$$4,2,4,6,2,6$$
$$4,2,4,6,6,2$$
$$4,2,6,4,6,8$$
Using the above method, you derive the value of the prime $n + k$. $k$ is known, so you can immediately deduce the value of $n$.
In fact, we can optimize that above table of differences to remove the unneeded trials and combine a few of them:
$$
\begin{matrix}
1 & 2,1 & 2,2 \\
2,4,2,4,2 & 2,4,2,4,6 & 2,4,6,2 \\
2,4,6,6 & 2,6,4,2,4 & 2,6,4,2,6 \\
2,6,4,6 & 4,2,4,2 & 4,2,4,6,2 \\
4,2,4,6,6 & 4,2,6 & 4,6,2 \\
4,6,6 & 4,6,8 & 6,2,6,4,2,4 \\
6,2,6,4,2,6 & 6,4,2,4 & 6,4,2,6 \\
6,4,6 & 6,6 & 6,8 \\
\end{matrix}
$$
The magic numbers to add to $k$ when guessing would be:
$$
\begin{matrix}
1 & 2,3 & 2,4 \\
2,6,8,12,14 & 2,6,8,12,18 & 2,6,12,14 \\
2,6,12,18 & 2,8,12,14,18 & 2,8,12,14,20 \\
2,8,12,18 & 4,6,10,12 & 4,6,10,16,18 \\
4,6,10,16,22 & 4,6,12 & 4,10,12 \\
4,10,16 & 4,10,18 & 6,8,14,18,20,24 \\
6,8,14,18,20,26 & 6,10,12,16 & 6,10,12,18 \\
6,10,16 & 6,12 & 6,14 \\
\end{matrix}
$$
It's imperative that the trials are done in order from left to right and top to bottom in this table, else, you will get false information. An example of one optimization is to avoid guessing when the only possible combination to continue with is 1 because we know that $n + k$ is prime.
An example:
- You tested $k + 4$, $k + 10$, and you're testing for $k + 12$
- You're now testing for $k + 16$
- You're now testing for $k + 18$
That last step is redundant. If $k + 16$ is composite, you can skip the $k + 18$ step because you know it will be prime.
I hope this is clear enough.