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机的资源,我们安装在主机上,就不用虚拟机来玩了.下面是 ...
随机推荐
- Spark MLlib之线性回归源代码分析
1.理论基础 线性回归(Linear Regression)问题属于监督学习(Supervised Learning)范畴,又称分类(Classification)或归纳学习(Inductive Le ...
- php简单的连接数据库
<?php $conn=@mysql_connect("localhost","root","") or die ("no& ...
- C语言开发函数库时利用不透明指针对外隐藏结构体细节
1 模块化设计要求库接口隐藏实现细节 作为一个函数库来说,尽力降低和其调用方的耦合.是最主要的设计标准. C语言,作为经典"程序=数据结构+算法"的践行者,在实现函数库的时候,必定 ...
- Java图形界面(GUI)——如何将JTable成功放入面板
在这次课程设计中,大部分内容都设计的很流畅,没有遇到太大的问题,但在面板中加入JTable时确实花费了一部分时间,在此将解决办法总结出来: 定义控件: JPanel panel = new JPane ...
- angular4 select 绑定(ngModel)对象
欢迎加入前端交流群交流知识&&获取视频资料:749539640 <h1>My Application</h1> <select [(ngModel)]=& ...
- 2.2.3 修改JSX代码
/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { ...
- 记录,javascript中对象的属性名是字符串,却可以不用引号
问题描述:今日看书,里面介绍js的对象的属性名是包括空字符串在内的所以字符串 问题来了,我们平时定义的对象如下,是没有引号""or’'的 var someone = { f ...
- BZOJ 3991 set维护dfs序
思路: set按照dfn排序 两点之间的距离可以O(logn)算出来 加一个点-> now ans+=dis(pre,now)+dis(now,next)-dis(pre-next); 删一个点 ...
- ACM-ICPC北京赛区[2017-11-19]
Domains K-Dimensional Foil Graph Chinese Checkers Cats and Fish #include<stdio.h> #include< ...
- JavaScript获取非行间样式
<html> <head> <meta charset="utf-8"> <title>无标题文档</title> &l ...