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


$ include "seed7_05.s7i";
 
const func boolean: kprime (in var integer: number, in integer: k) is func
  result
    var boolean: kprime is FALSE;
  local
    var integer: p is 2;
    var integer: f is 0;
  begin
    while f < k and p * p <= number do
      while number rem p = 0 do
        number := number div p;
        incr(f);
      end while;
      incr(p);
    end while;
    kprime := f + ord(number > 1) = k;
  end func;
 
const proc: main is func
  local
    var integer: k is 0;
    var integer: number is 0;
    var integer: count is 0;
  begin
    for k range 1 to 5 do
      write("k = " <& k <& ":");
      count := 0;
      for number range 2 to integer.last until count >= 10 do
        if kprime(number, k) then
          write(" " <& number);
          incr(count);
        end if;
      end for;
      writeln;
    end for;
  end func;