Илиян обнови решението на 03.05.2012 00:43 (преди над 12 години)
+def primes():
+ found_primes = [2]
+ yield 2
+ current_num = found_primes[-1]
+ while True:
+ current_num += 1
+ if all((current_num % prime_num for prime_num in found_primes)):
+ found_primes.append(current_num)
+ yield current_num
+
+
+def semiprimes():
+ prime_generator = primes()
+ prime_list = []
+ last = 1
+ while True:
+ prime_list.append(next(prime_generator))
+ mult = [x * y for x in prime_list for y in prime_list if x * y > last]
+ last = min(mult)
+ #min_pair = prime_list[-1] ** 2
+ #for x in prime_list:
+ # for y in prime_list:
+ # if x * y > last and x * y < min_pair:
+ # min_pair = x * y
+ #last = min_pair
+ yield last