Summation of primes
是我算法不对,还是笔记本CPU太差?
我优化了两次,还是花了三四个小时来得到结果。
在输出上加1就是最终结果。
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
def isprime(n):
boolisprime = True
for i in xrange(3,n):
if n % i == 0:
boolisprime = False
break
return boolisprime
def primenumber(n):
i = 1
sumprime = 0
while True:
if isprime(i) == True:
sumprime += i
print i,sumprime
if i > n:
break
i += 2
return sumprime
print primenumber(2000000)+1
Note: This problem has been changed recently, please check that you are using the right parameters.
-->
Summation of primes的更多相关文章
- projecteuler 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
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 ...
- PE 001~010
题意: 001(Multiples of 3 and 5):对小于1000的被3或5整除的数字求和. 002(Even Fibonacci numbers):斐波那契数列中小于等于4 000 000的 ...
- 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 ...
- PE刷题记
PE 中文翻译 最喜欢做这种很有意思的数学题了虽然数学很垃圾 但是这个网站的提交方式好鬼畜啊qwq 1.Multiples of 3 and 5 直接枚举 2.Even Fibonacci numbe ...
- Python练习题 038:Project Euler 010:两百万以内所有素数之和
本题来自 Project Euler 第10题:https://projecteuler.net/problem=10 # Project Euler: Problem 10: Summation o ...
- Summation of Four Primes - PC110705
欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/uva10168.html 原创:Summ ...
- UVA 10168 Summation of Four Primes(数论)
Summation of Four Primes Input: standard input Output: standard output Time Limit: 4 seconds Euler p ...
随机推荐
- hyperVisors
容器有效地将由单个操作系统管理的资源划分到孤立的组中,以更好地在孤立的组之间平衡有冲突的资源使用需求 期望继续进军中国市场 就像IBM公司,惠普公司和戴尔公司在中国服务器市场的霸主地位一样,Inspu ...
- powershell利用winform批量执行tsql语句
#加载.net的winform模块 [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $app= ...
- EasyUEFI
---------------------------------http://www.easyuefi.com/downloads/EasyUEFI_Setup.exe--------------- ...
- TortoiseGit上传代码到GitHub
Github是管理软件开发的首选托管网站,12306的火车票插件一时让国内当时很多小白开发者(当然也包括我)认识到了这个网站.GitHub可以托管各种git库,并提供一个web界面,与 SourceF ...
- ceph主要数据结构解析2-Rados.h文件
(1)文件系统id结构:16个字符组成 struct ceph_fsid { unsigned char fsid[16]; }; 以及对应的比较函数: static inline int ceph_ ...
- Amoeba是一个类似MySQL Proxy的分布式数据库中间代理层软件,是由陈思儒开发的一个开源的java项目
http://www.cnblogs.com/xiaocen/p/3736095.html amoeba实现mysql读写分离 application shang 2年前 (2013-03-28) ...
- Java基础知识强化89:Date类之Data类概述及其方法
1. Date类概述 类Date表示特定的瞬间,精确到毫秒 2. 构造方法 public Date():根据当前默认毫秒值创建日期对象 public Date(long date):根据给定的毫秒值创 ...
- #include<iostream.h>与#include<iostream> using namespace std的区别
所谓namespace,是指标识符的各种可见范围.C++标准程序库中的所有标识符都被定义于一个名为std的namespace中. 一 :<iostream>和<iostream.h ...
- Dreamweaver管理Svn控制器内容
一直以来很多人使用Dreamweaver来写css和xhtml.同时如果是应用于一个多人开发的项目的时候大家会使用svn或cvs来做版本控制的工作.但是可惜的是没有听说 Dreamweaver可以与版 ...
- SQL 查询字段为值不为空
方法一sql="select * from table where id<>null " or sql="select ...