摘要: Problem: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million.问题: 小于10的所有素数的和为 17。求小与2,000,000的所有素数的和。方法: 筛法求素数。View Code def primes(n): if n<2: raise StopIteration else: yield 2 l=[True for i in range((n-1)//2)] for i in range(len(l)): if l[i]: y 阅读全文
posted @ 2011-06-07 10:01 class 阅读(421) 评论(0) 推荐(0) 编辑