A number is an   attractive number   if the number of its prime factors (whether distinct or not) is also prime.



Example

The number   20,   whose prime decomposition is   2 × 2 × 5,   is an   attractive number   because the number of its prime factors   (3)   is also prime.



Task

Show sequence items up to   120.



Reference

   The OEIS entry:   A063989: Numbers with a prime number of prime divisors.


attractive: procedure options(main);
    %replace MAX by 120;
    declare prime(1:MAX) bit(1);
 
    sieve: procedure;
        declare (i, j, sqm) fixed;
        prime(1) = 0;
        do i=2 to MAX; prime(i) = '1'b; end;
 
        sqm = sqrt(MAX);
        do i=2 to sqm;
            if prime(i) then do j=i*2 to MAX by i;
                prime(j) = '0'b;
            end;
        end;
    end sieve;
 
    factors: procedure(nn) returns(fixed);
        declare (f, i, n, nn) fixed;
        n = nn;
        f = 0;
        do i=2 to n;
            if prime(i) then do while(mod(n,i) = 0);
                f = f+1;
                n = n/i;
            end;
        end;
        return(f);
    end factors;
 
    attractive: procedure(n) returns(bit(1));
        declare n fixed;
        return(prime(factors(n)));
    end attractive;
 
    declare (i, col) fixed;
    i = 0;
    col = 0;
    call sieve();
    do i=2 to MAX;
        if attractive(i) then do;
            put edit(i) (F(4));
            col = col + 1;
            if mod(col,18) = 0 then put skip;
        end;
    end;
end attractive;