Габриела обнови решението на 03.05.2012 00:24 (преди над 12 години)
+def is_prime(number):
+ return all([number % div for div in range(2, number)])
+
+def primes():
+ number = 2
+ while True:
+ if is_prime(number):
+ yield number
+ number += 1
+
+def semiprimes():
+ yield 4
+ number = 6
+ while True:
+ for factor in range(2, number):
+ if is_prime(factor):
+ if number % factor:
+ continue
+ quotient = number // factor
+ if is_prime(quotient):
+ yield number
+ break
+ number += 1