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


fn k_prime(n int, k int) bool {
    mut nf := 0
    mut nn := n
    for i in 2 .. nn+1 {
        for nn % i == 0 {
            if nf == k {
                return false
            }
            nf++
            nn/=i
        }
    }
    return nf == k
}
 
fn gen(k int, n int) []int {
    mut r := []int{len:n}
    mut nx := 2
    for i in 0 .. n {
        for !k_prime(nx, k) {
            nx++
        }
        r[i] = nx
        nx++
    }
    return r
}
 
fn main(){
    for k in 1..6 {
        println('$k ${gen(k,10)}')
    }
}