Skip to content

Instantly share code, notes, and snippets.

@lyricat
Created August 15, 2012 13:00
Show Gist options
  • Save lyricat/3359927 to your computer and use it in GitHub Desktop.
Save lyricat/3359927 to your computer and use it in GitHub Desktop.
prime sieve
def Generate():
i = 2
while True:
yield i
i += 1
def Filter(ig, prime):
while True:
i = ig.next()
if i % prime != 0:
yield i
if __name__ == "__main__":
ig = Generate()
for i in range (0, 20):
prime = ig.next()
print prime
primeg = Filter(ig, prime)
ig = primeg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment