Павлина обнови решението на 01.05.2012 00:29 (преди над 12 години)
+def primes():
+ number = 2
+ while True:
+ if all([number % divisor for divisor in range(2, number)]):
+ yield number
+ number += 1
+
+
+def isPrime(num):
+ p = primes()
+ i = next(p)
+ while i <= num:
+ if num == i:
+ return True
+ i = next(p)
+ return False
+
+
+def dividend(num):
+ for i in range(2, num + 1):
+ if isPrime(i) and num % i == 0:
+ return num // i
+ else:
+ return 0
+
+
+def semiprimes():
+ number = 4
+ while True:
+ p = dividend(number)
+ if p != 0:
+ q = dividend(p)
+ if q == 1:
+ yield number
+ number += 1