def multipli(n,b): c = [] x = n i = 1 while x<=b: c[0:0]=[x] i = i+1 x = i*n return set(c) def eratostene(nmax): L = set(range(3,nmax+1,2)) c =set([]) while len(L)>0: k = min(L) c.add(k) L = L - multipli(k,nmax) return c