Марин обнови решението на 02.05.2012 22:59 (преди над 12 години)
+def primes():
+ number = 2
+ while True:
+ if all([number % divisor for divisor in range(2, number)]):
+ yield number
+ number += 1
+
+
+def get_devisor(semiprime_num):
+ for devisor in range(2, semiprime_num-1):
+ if semiprime_num % devisor == 0:
+ return devisor
+
+
+def semiprimes():
+ semiprime_num = 1
+ while True:
+ devisor = get_devisor(semiprime_num)
+ if devisor != None:
+ factor = get_devisor(semiprime_num // devisor)
+ else:
+ factor = False
+ if factor == None:
+ yield semiprime_num
+ semiprime_num = semiprime_num + 1