Никола обнови решението на 03.05.2012 03:15 (преди над 12 години)
+def is_prime(number):
+ return all([number % divisor for divisor in range(2, int(number ** 0.5 + 1))])
+
+
+def primes():
+ number = 2
+ while True:
+ if is_prime(number):
+ yield number
+ number += 1
+
+
+def semiprimes():
+ number = 4
+ while True:
+ for i in range(2, number):
+ if is_prime(i) and number % i == 0:
+ if is_prime(number // i):
+ yield number
+ break
+ number += 1