Димитър обнови решението на 25.04.2012 14:19 (преди над 12 години)
+def trial_division(integer):
+ return all([integer % x for x in range(2, integer)])
+def is_semiprime(integer):
+ prime_a = 2
+ while True:
+ if prime_a == integer:
+ return False
+ if (not integer % prime_a and
+ trial_division(prime_a) and
+ trial_division(int(integer / prime_a))):
+ return True
+ prime_a += 1
+def primes():
+ curent = 2
+ while True:
+ if trial_division(curent):
+ yield curent
+ curent += 1
+def semiprimes():
+ while True:
+ semiprime = 2
+ while True:
+ semiprime += 1
+ if is_semiprime(semiprime):
+ yield semiprime
+
+