Никола обнови решението на 03.05.2012 17:19 (преди над 12 години)
+
+def primes():
+ yield 2
+ number = 3
+ while True:
+ if all([number % divisor for divisor in range(2, number)]):
+ yield number
+ number += 2
+
+
+def isprime(n):
+ for m in range(2,n):
+ if n%m==0:
+ return 0
+ return 1
+
+
+def inlist(el,lst):
+ for m in lst:
+ if m==el:
+ return 1
+ return 0
+
+
+def semiprimes():
+ number=3
+ while True:
+ already=[]
+ for devisor in range(2,number):
+ if number%devisor==0:
+ t=number/devisor
+ snd_devisor=int(t)
+ if isprime(devisor)==1 and isprime(snd_devisor)==1 and inlist(snd_devisor,already)==0:
+ yield number
+ already.append(devisor)
+ number+=1
+
+