Skip to content

Instantly share code, notes, and snippets.

@gregglind
Created September 7, 2010 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregglind/569165 to your computer and use it in GitHub Desktop.
Save gregglind/569165 to your computer and use it in GitHub Desktop.
import sys
def pr(x):
sys.stdout.write(str(x)+"\n")
def gen_primes_1a():
seq = count(2)
seq = ((x,0) for x in seq)
while True:
p,old = seq.next()
seq = ((x,pr("%i over %i" %(x,p))) for (x,blah) in seq if x%p)
yield p
print(list(islice(gen_primes_1a(), 10)))
# this shows the problem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment