project euler #10:Summation of primes,,The sum of t
project euler #10:Summation of primes,,The sum of t
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
def PrimeUnder(n): p=3 prim=[2] while p<n: result = True for i in prim: root = p**0.5+1 if i>root: break if p%i == 0: result = False break if result==True: prim.append(p) #print(p) p=p+2 return sum(prim)print(PrimeUnder(2000000))#该片段来自于http://byrx.net
相关内容
- Python寻找第k小的元素,Python第k元素,# -*- coding
- Flask 淘宝数据再开发WEB,flask淘宝开发web,https://gith
- python count,python,# _*_ coding
- n的阶乘末尾有多少个0,阶乘末尾,请写一段程序计算
- Redis优先列队 --cherryq,redis--cherryq,这个Queue是多列队列
- python中连续多次输出相同字符串的方法,python输出字符
- NHibernate代码生成器,,使用pyodbc连接MS
- 下载网络图像,网络图像,import osimp
- python求解水仙花数,python求解水仙花,#!/usr/bin/p
- 使用Tornado开发Github用户活跃度排名应用,tornadogithub,
评论关闭