/* The first part consider the cases of squares of primes, the second part the remaining cases */ semiprimep(n):=if integerp(sqrt(n)) and primep(sqrt(n)) then true else lambda([x],length(ifactors(x))=2 and unique(map(second,ifactors(x)))=[1])(n)$ /* Example */ sublist(makelist(i,i,100),semiprimep);