def nodoppioni(x): dep = x[:] for k in x: dep.remove(k) if not(k in dep): dep.append(k) return dep def intersezione(a,b): d = nodoppioni(a) e = nodoppioni(b) c = [] for x in d: if x in e: c[0:0]=[x] return c def unione(a,b): d = nodoppioni(a) e = nodoppioni(b) c = e for x in d: if not x in e: c[0:0]=[x] return c def differenza(a,b): d = nodoppioni(a) e = nodoppioni(b) c=[] for x in d: if not x in e: c[0:0]=[x] return c def multipli(n,b): c = [] x = n i = 1 while x<=b: c[0:0]=[x] i = i+1 x = i*n return c def eratostene(nmax): Lista = range(3,nmax+1,2) c =[] while len(Lista)>0: k = min(Lista) c[0:0]=[k] Lista = differenza(Lista,multipli(k,nmax)) return c