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


 
for ap = 1 to 5
    see "k = " + ap + ":" 
    aList = []
    for n = 1 to 200
        num = 0
        for nr = 1 to n
            if n%nr=0 and isPrime(nr)=1
               num = num + 1 
               pr = nr
               while true
                     pr = pr * nr
                     if n%pr = 0
                        num = num + 1
                     else exit ok
               end ok
        next  
        if (ap = 1 and isPrime(n) = 1) or (ap > 1 and num = ap)
           add(aList, n)
           if len(aList)=10 exit ok ok
     next
     for m = 1 to len(aList)
           see " " + aList[m]
     next 
     see nl
next
 
func isPrime num
     if (num <= 1) return 0 ok
     if (num % 2 = 0 and num != 2) return 0 ok
     for i = 3 to floor(num / 2) -1 step 2
         if (num % i = 0) return 0 ok
     next
     return 1
 