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



10  'Almost prime
20  FOR K% = 1 TO 5
30   PRINT "k = "; K%; ":";
40   LET I% = 2
50   LET C% = 0
60   WHILE C% < 10  
70    LET AN% = I%: GOSUB 1000
80    IF ISKPRIME <> 0 THEN PRINT USING " ###"; I%;: LET C% = C% + 1
90    LET I% = I% + 1
100  WEND
110  PRINT
120 NEXT K%
130 END 

995  ' Check if n (AN%) is a k (K%) prime
1000 LET F% = 0
1010 FOR J% = 2 TO AN%
1020  WHILE AN% MOD J% = 0
1030   IF F% = K% THEN LET ISKPRIME = 0: RETURN
1040   LET F% = F% + 1
1050   LET AN% = AN% \ J%
1060  WEND
1070 NEXT J%
1080 LET ISKPRIME = (F% = K%)
1090 RETURN
 