Светлин обнови решението на 01.05.2012 21:16 (преди над 12 години)
+import math
+def is_prime(x):
+ for j in range(2, math.ceil(math.sqrt(x)) + 1):
+ if x != j and x % j == 0:
+ return 0
+ return 1
+
+def primes():
+ i = 2
+ while 1:
+ if is_prime(i):
+ yield i
+ i = i + 1
+
+def is_proiz(x):
+ for j in range(2, x):
+ if not is_prime(j) and x % j == 0 or is_prime(x):
+ return 0
+ return 1
+
+
+def semiprimes():
+ i = 4
+ while 1:
+ if is_proiz(i):
+ yield i
+ i = i + 1
+