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.


sieve = proc (max: int) returns (array[bool]) 
    prime: array[bool] := array[bool]$fill(1,max,true)
    prime[1] := false
    for p: int in int$from_to(2, max/2) do
        if prime[p] then
            for c: int in int$from_to_by(p*p, max, p) do
                prime[c] := false
            end
        end
    end
    return(prime)
end sieve
 
n_factors = proc (n: int, prime: array[bool]) returns (int)
    count: int := 0
    i: int := 2
    while i<=n do 
        if prime[i] then
            while n//i=0 do
                count := count + 1
                n := n/i
            end
        end
        i := i + 1 
    end
    return(count)
end n_factors
 
start_up = proc ()
    MAX = 120
    po: stream := stream$primary_output()
    prime: array[bool] := sieve(MAX)
    col: int := 0
    for i: int in int$from_to(2, MAX) do
        if prime[n_factors(i,prime)] then
            stream$putright(po, int$unparse(i), 4)
            col := col + 1
            if col//15 = 0 then stream$putl(po, "") end
        end
    end
end start_up