primeFactory = function(n=2) if n < 2 then return "" for i in range(2, n) p = floor(n / i) q = n % i if not q then return str(i) + " " + str(primeFactory(p)) end for return n end function getAlmostPrimes = function(k) almost = [] n = 2 while almost.len < 10 primes = primeFactory(n).trim.split if primes.len == k then almost.push(n) n += 1 end while return almost end function for i in range(1, 5) print i + ": " + getAlmostPrimes(i) end for