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


 
    REM Almost prime
    LET K=1
10  IF K>5 THEN END
    PRINT "k = ",K,":"
    LET I=2
    LET C=0
20  IF C>=10 THEN GOTO 40
    LET N=I
    GOSUB 500
    IF P=0 THEN GOTO 30
    PRINT I
    LET C=C+1
30  LET I=I+1
    GOTO 20
40  LET K=K+1
    GOTO 10
 
    REM Check if N is a K prime (result: P)
500 LET F=0
    LET J=2
510 IF (N/J)*J<>N THEN GOTO 520
    IF F=K THEN GOTO 530
    LET F=F+1
    LET N=N/J
    GOTO 510
520 LET J=J+1
    IF J<=N THEN GOTO 510
    LET P=0
    IF F=K THEN LET P=-1
    RETURN
530 LET P=0
    RETURN
 