Hacker News new | past | comments | ask | show | jobs | submit login

http://codepad.org/MzI2fqg7

  from itertools import *

  primes = (i for i in count(2) if all(imap(lambda x:i%x,xrange(2,i/2))))
My Python code for a generator expression to loop on prime numbers.



you only need to check for divisors up to sqrt(i)

http://codepad.org/VMSqtLbS


Arghh, you are right. I wonder if this will make any difference in my Project Euler problem solutions.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: