Рая обнови решението на 30.04.2012 20:29 (преди над 12 години)
+def primes():
+ number = 2
+ while True:
+ if is_prime(number):
+ yield number
+ number += 1
+
+def semiprimes():
+ test_semiprime = 4
+ while True:
+ for prime in primes():
+ if prime < test_semiprime:
+ if not test_semiprime % prime:
+ if is_prime(int(test_semiprime / prime)):
+ yield test_semiprime
+ break
+ else:
+ break
+ test_semiprime += 1
+
+def is_prime(number):
+ return all([number % divisor for divisor in range(2, int(number / 2 + 1))])