Welcome, guest | Sign In | My Account | Store | Cart
def prime(n):
    def z(x):
        if x :return True
        return False
    num1=range(0,n+1); num2=int(n**0.5) +1
    for k in range(2,num2):
        num0=range(k,n+1,k);del num0[0]     
        for i in num0:
            num1[i]=0
    return filter(z, num1)

print prime(102)

Diff to Previous Revision

--- revision 5 2014-09-18 13:41:07
+++ revision 6 2014-09-20 19:33:41
@@ -1,6 +1,12 @@
-n=102
-nump = [2] + range(3, n+1, 2) 
-for i in range(3, int((n**0.5)+1),2): 
-    nump = filter(lambda x: x == i or x % i, nump)
- 
-print nump
+def prime(n):
+    def z(x):
+        if x :return True
+        return False
+    num1=range(0,n+1); num2=int(n**0.5) +1
+    for k in range(2,num2):
+        num0=range(k,n+1,k);del num0[0]     
+        for i in num0:
+            num1[i]=0
+    return filter(z, num1)
+
+print prime(102)

History