Борислав обнови решението на 23.04.2012 18:37 (преди над 12 години)
+import itertools
+import math
+def isprimeproduct(n):
+ prime_dividers = [x for x in range(2, (n >> 1) + 1) if isprime(x)]
+ func = itertools.combinations_with_replacement
+ return any(map(lambda x: x[0] * x[1] == n, func(prime_dividers, 2)))
+def isprime(n):
+ return all([n % x != 0 for x in range(2, int(math.sqrt(n)) + 1)])
+def primes():
+ return filter(lambda x: isprime(x), itertools.count(2))
+def semiprimes():
+ return filter(lambda x: isprimeproduct(x), itertools.count(4))