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.
True
for truthy and2
orFalse
for falsy (inconsistent falsy values)? \$\endgroup\$2 * 2 * 2 * 3 * 3
a semi-prime? What about5 * 5
? \$\endgroup\$5*5
is semi-prime,2*2*2*3*3
is not. I said exactly two. \$\endgroup\$2*2*2*3*3
has exactly two prime factors, namely2
and3
, and5*5
has one prime factor, namely5
.) Maybe you could edit that into the question? \$\endgroup\$