27
A number is a Chen prime if it satisfies two conditions:
- It is prime itself
- Itself plus two is either a prime or a semi-prime.
A prime is a number where it has exactly two divisors and those divisors consist of itself and one.
A semi-prime is a number which is the product of two primes. (Note that 12 = 2*2*3 is not semi-prime, but 25 = 5*5 is).
Your task is to determine if a number is a Chen prime. You should output any truthy value for yes and any falsy value for no.
The input will be any integer greater than or equal to one. It may also be taken as a string, character array, or an array or digits.
Examples:
101 -> truthy
223 -> falsy
233 -> truthy
1 -> falsy
This is OEIS A109611.
This is, in part, inspired by Am I a Sophie Germain prime? which, unfortunately, got closed as a duplicate, so I'm posting a somewhat related challenge which isn't a duplicate.
Can we return
Truefor truthy and2orFalsefor falsy (inconsistent falsy values)? – Mr. Xcoder – 2017-07-10T12:04:14.993@Mr.Xcoder Never said you couldn't – Okx – 2017-07-10T12:06:15.223
For a semi-prime, does "exactly two prime factors" count multiplicity? Is
2 * 2 * 2 * 3 * 3a semi-prime? What about5 * 5? – Not a tree – 2017-07-10T12:09:56.623@Notatree
5*5is semi-prime,2*2*2*3*3is not. I said exactly two. – Okx – 2017-07-10T12:11:36.737So it does count multiplicity, then? (You could argue that
2*2*2*3*3has exactly two prime factors, namely2and3, and5*5has one prime factor, namely5.) Maybe you could edit that into the question? – Not a tree – 2017-07-10T12:17:24.497Can I use
0for truthy and anything else for falsy? – Titus – 2017-07-10T16:17:03.477@Titus Is it truthy in your language? – Okx – 2017-07-10T16:20:04.477
Is
2falsy? (Mr. Xcoder) – Titus – 2017-07-10T16:20:39.817@Titus No. (Sorry, late response) – Okx – 2017-08-07T19:12:11.503