Mercurial > hg > config
changeset 253:8593b0384d3e
add a function for computing primes
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 10 Dec 2012 11:08:21 -0800 |
parents | f8b65bb57678 |
children | 56537ed6ebc6 |
files | python/prime.py |
diffstat | 1 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/python/prime.py Thu Dec 06 15:16:39 2012 -0800 +++ b/python/prime.py Mon Dec 10 11:08:21 2012 -0800 @@ -7,6 +7,12 @@ return False return True +def primes(n): + return [i for i in range(2,n) + if not [True for j in range(2,1 + i/2) + if not i%j]] + + if __name__ == '__main__': import sys for arg in sys.argv[1:]: