Илиян обнови решението на 26.04.2012 23:56 (преди над 12 години)
+def primes():
+ number = 2
+ while True:
+ if check_if_is_prime(number) == True:
+ yield number
+ number += 1
+
+
+def semiprimes():
+ number = 4
+ last_semiprime = 0
+ while True:
+ for first_divisor in range(2, number):
+ if number % first_divisor == 0:
+ if check_if_is_prime(first_divisor) == True:
+ second_divisor = number // first_divisor
+ if (check_if_is_prime(second_divisor) == True
+ and last_semiprime != number):
+ last_semiprime = number
+ yield number
+ number += 1
+
+
+def check_if_is_prime(number):
+ for divisor in range(2, number):
+ if number % divisor == 0:
+ return False
+ return True