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.


$ include "seed7_05.s7i";
 
const func boolean: semiPrime (in var integer: n) is func
  result
    var boolean: isSemiPrime is TRUE;
  local
    var integer: p is 2;
    var integer: f is 0;
  begin
    while f < 2 and p**2 <= n do
      while n rem p = 0 do
        n := n div p;
        incr(f);
      end while;
      incr(p);
    end while;
    isSemiPrime := f + ord(n > 1) = 2;
  end func;
 
const proc: main is func
  local
    var integer: v is 0;
  begin
    for v range 1675 to 1680 do
      writeln(v <& " -> " <& semiPrime(v));
    end for;
  end func;