Variable Prime "Twins"
Brachylog, 27 23 bytes
:1f
hS,?tye.:S+:.L*$pL,
Try it online!
Verify all testcases.
Predicate 0 (main predicate)
:1f Find all solutions of predicate 1
given Input as Input,
Unify Output with the set of all solutions.
Predicate 1 (auxiliary predicate)
hS,?tye.:S+:.L*$pL,
hS the first element of Input is S,
?tye. Output is an element between 0 and
the last element of Input,
.:S+:.L The list [Output+S,Output] is L,
L*$pL The product of L, prime-factorized, is still L
05AB1E, 9 bytes
Code:
LDpÏDI+pÏ
Uses the CP-1252 encoding. Try it online!.
Jelly, 8 7 bytes
+ÆR©_f®
Try it online!
Explanation
+ add the upper bound and the difference
ÆR find all primes up to that number
© save that in the register
_ subtract the difference from each
f® remove anything not in the original prime list