A   k-Almost-prime   is a natural number   



n


{\displaystyle n}

   that is the product of   



k


{\displaystyle k}

   (possibly identical) primes.



Example

1-almost-primes,   where   



k
=
1


{\displaystyle k=1}

,   are the prime numbers themselves.

2-almost-primes,   where   



k
=
2


{\displaystyle k=2}

,   are the   semiprimes.



Task

Write a function/method/subroutine/... that generates k-almost primes and use it to create a table here of the first ten members of k-Almost primes for   



1
<=
K
<=
5


{\displaystyle 1<=K<=5}

.



Related tasks

   Semiprime
   Category:Prime Numbers


almost_prime: procedure options(main);
    kprime: procedure(nn, k) returns(bit);
        declare (n, nn, k, p, f) fixed;
        f = 0;
        n = nn;
        do p=2 repeat(p+1) while(f<k & p*p <= n);
            do n=n repeat(n/p) while(mod(n,p) = 0);
                f = f+1;
            end;
        end;
        return(f + (n>1) = k);
    end kprime;
 
    declare (i, c, k) fixed;
    do k=1 to 5;
        put edit('k = ',k,':') (A,F(1),A);
        c = 0;
        do i=2 repeat(i+1) while(c<10);
            if kprime(i,k) then do;
                put edit(i) (F(4));
                c = c+1;
            end;
        end;
        put skip;
    end;
end almost_prime;