Мирослав обнови решението на 03.05.2012 15:50 (преди над 12 години)
+def primes():
+ number = 2
+ while True:
+ if all([number % divisor for divisor in range(2, number)]):
+ yield number
+ number += 1
+
+
+def is_whole(n):
+ if n % 1 != 0:
+ return False
+ return True
+
+
+def is_prime(n):
+ import re
+ if not is_whole(n):
+ return False
+ return re.match(r'^1?$|^(11+?)\1+$', '1' * int(n)) == None
+
+
+def semiprimes():
+ number = 4
+ while True:
+ pr = primes()
+ x = next(pr)
+ while x < number:
+ if is_prime(number / x):
+ yield number
+ break
+ x = next(pr)
+ number += 1