23
5
An Integer is prime if and only if it is positive and has exactly 2 distinct divisors: 1 and itself. A twin prime pair is made of two elements: p
and p±2
, that are both prime.
You will be given a positive integer as input. Your task is to return a truthy / falsy depending on whether the given integer belongs to a twin pair, following the standard decision-problem rules (the values need to be consistent).
Test Cases
Truthy (Twin Primes):
3, 5, 7, 11, 13, 17, 19, 29, 31, 41, 43
Falsy (not Twin Primes):
2, 15, 20, 23, 37, 47, 97, 120, 566
This is code-golf, so the shortest code in bytes wins!
is 13 a prime twin? – LiefdeWen – 2017-07-24T11:58:03.467
@LiefdeWen Yes, because it belongs to the pair (11, 13) – daniero – 2017-07-24T12:05:17.043