Problem 10
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的更多相关文章
- 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 ...
- uoj problem 10
uoj problem 10 题目大意: 给定任务若干,每个任务在\(t_i\)收到,需要\(s_i\)秒去完成,优先级为\(p_i\) 你采用如下策略: 每一秒开始时,先收到所有在该秒出现的任务,然 ...
- leetcode problem 10 Regular Expression Matching(动态规划)
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...
- (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 ...
- Problem 10: Summation of primes
def primeslist(max): ''' 求max值以内的质数序列 ''' a = [True]*(max+1) a[0],a[1]=False,False for index in rang ...
- Common Bugs in C Programming
There are some Common Bugs in C Programming. Most of the contents are directly from or modified from ...
- 一个简单的 Web 服务器 [未完成]
最近学习C++,linux和网络编程,想做个小(mini)项目. 就去搜索引擎, 开源中国, Sourceforge上找http server的项目. 好吧,也去了知乎. 知乎上程序员氛围好, ...
- electrica writeup
关于 caesum.com 网上上的题目,分类有Sokoban,Ciphers,Maths,Executables,Programming,Steganography,Misc.题目有点难度,在努力奋 ...
- android和linux开发环境建立(驱动层)
流程:安装ubutu14.04操作系统==>安装各种库和应用程序并配置环境变量 1,install ubuntu14.04 为了完全释放PC机的资源,我们安装在主机上,就不用虚拟机来玩了.下面是 ...
随机推荐
- Tomcat容器 web.xml具体解释
<init-param> <param-name>debug</param-name> <param-value>0</param-value&g ...
- luogu2606 排列计数
题目大意 求满足下列条件的排列$P$的数量:$\forall P_i, P_i>P_{\lfloor \frac{i}{2}\rfloor}$. 思路 从下标入手 反过来想,也就是对$\fora ...
- 利用SQLite在android上实现增删改查
利用SQLite在android上实现增删改查 方法: 一.直接利用database.execSQL()方法输入完整sql语句进行操作 这种方法适用于复杂的sql语句,比如多表查询等等 这里适合于增删 ...
- 循环神经网络(RNN, Recurrent Neural Networks)——无非引入了环,解决时间序列问题
摘自:http://blog.csdn.net/heyongluoyao8/article/details/48636251 不同于传统的FNNs(Feed-forward Neural Networ ...
- EOJ 3031 二进制倒置
题目描述 给定一个整数 n(0≤n≤10100).将 n 的 334 位二进制表示形式(不包括开头可能的值为 0 的位,n=0 表示为 1 位 0)前后倒置,输出倒置后的二进制数对应的整数. 例如:n ...
- Intellij IDEA社区版打包Maven项目成war包,并部署到tomcat上
转自:https://blog.csdn.net/yums467/article/details/51660683 需求分析 我们利用 Intellij idea社区版IDE开发了一个maven的sp ...
- Python3爬虫--两种方法(requests(urllib)和BeautifulSoup)爬取网站pdf
1.任务简介 本次任务是爬取IJCAI(国际人工智能联合会议)最新2018年的pdf论文文件. 本次编码用到了正则表达式从html里面提取信息,如下对正则表达式匹配规则作简要的介绍. 2.正则表达式规 ...
- hihoCoder-1830 2018亚洲区预选赛北京赛站网络赛 C.Cheat 模拟
题面 题意:4个人围一圈坐着,每个人13张牌,然后从第一个人开始,必须按照A-K的顺序出牌,一个人出牌后,剩下的人依次可以选择是否质疑他,例如,第一个人现在必须出8(因为按照A-K顺序轮到了),可是他 ...
- Hadoop MapReduce编程 API入门系列之二次排序(十六)
不多说,直接上代码. -- ::, INFO [org.apache.hadoop.metrics.jvm.JvmMetrics] - Initializing JVM Metrics with pr ...
- Bootstrap 模态框使用
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...