Стоян обнови решението на 03.05.2012 01:42 (преди над 12 години)
+def is_prime(number):
+ for i in range(2, number):
+ if number % i == 0:
+ return False
+ return True
+
+
+def primes():
+ number = 2
+ while True:
+ if is_prime(number):
+ yield number
+ number += 1
+
+
+def is_composed_by_primes(number):
+ for i in range(2, number):
+ for j in range(2, number):
+ if number == i * j and is_prime(i) and is_prime(j):
+ return True
+ return False
+
+
+def semiprimes():
+ number = 4
+ while True:
+ if is_composed_by_primes(number):
+ yield number
+ number += 1