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.


 
PROGRAM SEMIPRIME_NUMBER
 
!VAR I%
 
PROCEDURE SEMIPRIME(N%->RESULT%)
   LOCAL F%,P%
   P%=2
   LOOP
       EXIT IF NOT(F%<2 AND P%*P%<=N%)
       WHILE (N% MOD P%)=0 DO
            N%=N% DIV P%
            F%+=1
       END WHILE
       P%+=1
    END LOOP
    RESULT%=F%-(N%>1)=2
END PROCEDURE
 
BEGIN
    PRINT(CHR$(12);) !CLS
    FOR I%=2 TO 100 DO
         SEMIPRIME(I%->RESULT%)
         IF RESULT% THEN PRINT(I%;) END IF
    END FOR
    PRINT
END PROGRAM
 