Husk, 9 bytes
→←ġo<⁰-İp
Try it online!
This is a really interesting question allowing a range of possible approaches (and Husk is a good fit for it; I learned the language for the challenge).
The TIO link contains a wrapper to run this function on all inputs from 1 to 10.
Explanation
→←ġo<⁰-İp
İp The (infinite) list of primes
ġ Group them, putting adjacent primes in the same group if
- the difference between them
<⁰ is less than the input
o (fix for a parser ambiguity that causes this parse to be chosen)
→ Take the last element of
← the first group
Grouping primes that are too close together means that the first break in the groups will be the first point at which the primes are sufficiently far apart, so we simply just need to find the prime just after the break.
Other potential solutions
Here's an 8-byte solution that, sadly, only works with even numbers as input (and thus isn't valid):
-⁰LU⁰mṗN
N On the infinite list of natural numbers
m replace each element with
ṗ 0 if composite, or a distinct number if prime
U Find the longest prefix with no repeated sublist of length
⁰ equal to the input
-⁰ Subtract the input from
L the length of that prefix
The idea is that when we have two primes that are a distance of (say) 6 apart, there'll be a sequence of five consecutive zeroes in the mṗN
sequence, which contains two identical sublists of length 4 (the first four zeroes and last four zeroes), but such a repetition cannot happen earlier (because as each prime is mapped to a unique number, any length-4 substrings before the first prime gap > 4 will contain a prime number, and the substring will therefore be unique as it's the only substring which contains that number in that position). Then we just have to subtract the trailing zeroes from the length of the prefix to get our answer.
This doesn't work with odd inputs because the sublist of input zeroes only occurs once rather than twice, so the code ends up finding the second point at which it occurs rather than the first.
OEIS A104138. – Mr. Xcoder – 2019-01-23T11:04:58.847
1It's interesting that on a language-by-language basis, most answers are considerably shorter than the answers to the exact duplicate posted in August 17. I'd conclude that the code-golfing skills of the community as a whole continue to grow. – nwellnhof – 2019-01-23T11:28:44.220
... or the golfing languages keep getting terser – Luis Mendo – 2019-01-23T22:33:03.160