Никола обнови решението на 03.05.2012 12:33 (преди над 12 години)
+def primes():
+ number = 2
+ while True:
+ if all([number % divisor for divisor in range(2, number)]):
+ yield number
+ number += 1
+
+def semiprimes():
+ next_prime = primes()
+ need_primes = [next(next_prime)]
+ number = 2
+ while True:
+ if number > need_primes[-1]:
+ need_primes.append(next(next_prime))
+ for i in need_primes:
+ if number % i == 0:
+ if number / i in need_primes:
+ yield number
+ number += 1
+ number += 1