Semiprime numbers are natural numbers that are products of exactly two (possibly equal) prime numbers.


Semiprimes   are also known as:

   semi-primes
   biprimes
   bi-primes
    2-almost    primes
   or simply:    P2  


Example
 
   1679  =  23 × 73  

(This particular number was chosen as the length of the Arecibo message).



Task

Write a function determining whether a given number is semiprime.



See also

 The Wikipedia article:  semiprime.
 The Wikipedia article:  almost prime.
 The OEIS sequence:  A001358: semiprimes  which has a shorter definition: the product of two primes.


 
# Output: a stream of proper factors (probably unsorted)
def proper_factors:
  range(2; 1 + sqrt|floor) as $i
  | if (. % $i) == 0 
    then (. / $i) as $r
    | if $i == $r then $i else $i, $r end
    else empty
    end;
 
def is_semiprime:
  . as $n
  | any(proper_factors; 
        is_prime and (($n / .) | (. == $n or is_prime) );
 