Галин обнови решението на 03.05.2012 14:44 (преди над 12 години)
+def primes():
+ prime_list = []
+ number = 2
+ while True:
+ is_prime = True
+ for prime in prime_list:
+ if (number % prime) == 0:
+ is_prime = False
+ continue
+ if is_prime:
+ yield number
+ prime_list.append(number)
+ number += 1
+
+
+def semiprimes():
+ prime_list = []
+ semiprime_list = []
+ number = 2
+ while True:
+ is_prime = True
+ for prime in prime_list:
+ if (number % prime) == 0:
+ is_prime = False
+ continue
+ if is_prime:
+ prime_list.append(number)
+ for prime in prime_list:
+ semiprime_list.append(prime * number)
+ else:
+ if number in semiprime_list:
+ yield number
+ number += 1