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


EnableExplicit
 
Procedure.b kprime(n.i, k.i)
  Define p.i = 2,
         f.i = 0
 
  While f < k And p*p <= n
    While n % p = 0
      n / p
      f + 1      
    Wend    
    p + 1
  Wend
 
  ProcedureReturn Bool(f + Bool(n > 1) = k)
 
EndProcedure
 
;___main____
If Not OpenConsole("Almost prime")
  End -1
EndIf
 
Define i.i,
       c.i,
       k.i
 
For k = 1 To 5
  Print("k = " + Str(k) + ":")
 
  i = 2
  c = 0
  While c < 10    
    If kprime(i, k)
      Print(RSet(Str(i),4))
      c + 1
    EndIf
    i + 1
  Wend  
  PrintN("")
Next
 
Input()