fork download
  1. from itertools import islice
  2.  
  3. def integers(): # 2,3,4,...
  4. n = 1
  5. while True:
  6. n += 1
  7. yield n
  8.  
  9. def sieve(s):
  10. x = next(s)
  11. yield x
  12. it = sieve(filter(lambda y: y % x, s))
  13. while True: yield next(it)
  14.  
  15. print( list( islice(sieve(integers()),890,900) ))
  16. # 390-400 0.11s 9.8MB
  17. # 590-600 0.18s 10.2MB
  18. # 890-900 0.34s 10.5MB
  19. # 990-1000 **run-time error: signal: 25 (SIGXFSZ)**
Success #stdin #stdout 0.35s 10488KB
stdin
Standard input is empty
stdout
[6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997]