Problem 10

# Problem_10.py
"""
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
找出两百万一下的质数之和
"""
import math
primes = [] for i in range(2, 2000001):
flag = True
for x in range(2, int(math.sqrt(i))+1):
if i % x == 0:
flag = False
if flag:
print(i)
primes.append(i) print(primes)
print(sum(primes))

Problem 10的更多相关文章

  1. Project Euler Problem 10

    Summation of primes Problem 10 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of ...

  2. uoj problem 10

    uoj problem 10 题目大意: 给定任务若干,每个任务在\(t_i\)收到,需要\(s_i\)秒去完成,优先级为\(p_i\) 你采用如下策略: 每一秒开始时,先收到所有在该秒出现的任务,然 ...

  3. leetcode problem 10 Regular Expression Matching(动态规划)

    Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...

  4. (Problem 10)Summation of primes

    The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two milli ...

  5. Problem 10: Summation of primes

    def primeslist(max): ''' 求max值以内的质数序列 ''' a = [True]*(max+1) a[0],a[1]=False,False for index in rang ...

  6. Common Bugs in C Programming

    There are some Common Bugs in C Programming. Most of the contents are directly from or modified from ...

  7. 一个简单的 Web 服务器 [未完成]

    最近学习C++,linux和网络编程,想做个小(mini)项目.  就去搜索引擎, 开源中国, Sourceforge上找http server的项目. 好吧,也去了知乎.    知乎上程序员氛围好, ...

  8. electrica writeup

    关于 caesum.com 网上上的题目,分类有Sokoban,Ciphers,Maths,Executables,Programming,Steganography,Misc.题目有点难度,在努力奋 ...

  9. android和linux开发环境建立(驱动层)

    流程:安装ubutu14.04操作系统==>安装各种库和应用程序并配置环境变量 1,install ubuntu14.04 为了完全释放PC机的资源,我们安装在主机上,就不用虚拟机来玩了.下面是 ...

随机推荐

  1. Android Studio Mac 快捷键整理分享

    代码高亮 OSX:Shift + Cmd + F7 Win/Linux:Alt + J 代码高亮向上查找 OSX:Shift + Cmd + G Win/Linux:Shift + F3 代码高亮向下 ...

  2. Ubuntu下启动Eclipse报错:A Java RunTime Environment (JRE) or Java Development Kit (JDK) must

    原以为是jdk的环境变量配置错误了,于是从网上找了各种配置环境变量的方法.也注意空格的问题,可无论怎么改,还是这样报错!后来在网上看到一种奇怪的方法.我也不知道为什么这样就OK了? 方法:进入你的ec ...

  3. VC++玩转Native Wifi API 2---Wifi on与wifi off

     有心栽花花不开,无心插柳柳成排. 今天要说的这个wifi on\off是在软件层面控制无线网卡的开和关. 问题听起来简单,调查起来复杂.但解决起来却也简单.关键函数便是Native wifi a ...

  4. Qt5.9 提供Qt Remote Objects,OAuth1 & OAuth2,重写了QML的GC

    Technology Preview Modules Qt Remote Objects - A module that allows you to easily share QObject inte ...

  5. MongoDB如何实现读写分离

    MongoDB如何实现读写分离 MongoDB复制集(Replica Set)通过存储多份数据副本来保证数据的高可靠,通过自动的主备切换机制来保证服务的高可用.但需要注意的时,连接副本集的姿势如果不对 ...

  6. 【POJ 2286】 The Rotation Game

    [题目链接] http://poj.org/problem?id=2286 [算法] IDA* [代码] #include <algorithm> #include <bitset& ...

  7. JavaScript:Browser 对象

    ylbtech-JavaScript:Browser 对象 1.  Window 对象返回顶部 1. Window 对象 Window 对象 Window 对象表示浏览器中打开的窗口. 如果文档包含框 ...

  8. js 数组包含

    function(arr,element){ return new RegExp('(^|,)'+element.toString()+'(,|$)').test(arr.toString()); }

  9. linux系统下块设备驱动程序

    顾名思义,块设备驱动程序就是支持以块的方式进行读写的设备.块设备和字符设备最大的区别在于读写数据的基本单元不同.块设备读写数据的基本单元为块,例 如磁盘通常为一个sector,而字符设备的基本单元为字 ...

  10. 2015 多校赛 第二场 1002 (hdu 5301)

    Description Your current task is to make a ground plan for a residential building located in HZXJHS. ...