是我算法不对,还是笔记本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的更多相关文章

  1. 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 ...

  2. (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 ...

  3. Problem 10: Summation of primes

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

  4. PE 001~010

    题意: 001(Multiples of 3 and 5):对小于1000的被3或5整除的数字求和. 002(Even Fibonacci numbers):斐波那契数列中小于等于4 000 000的 ...

  5. 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 ...

  6. PE刷题记

    PE 中文翻译 最喜欢做这种很有意思的数学题了虽然数学很垃圾 但是这个网站的提交方式好鬼畜啊qwq 1.Multiples of 3 and 5 直接枚举 2.Even Fibonacci numbe ...

  7. Python练习题 038:Project Euler 010:两百万以内所有素数之和

    本题来自 Project Euler 第10题:https://projecteuler.net/problem=10 # Project Euler: Problem 10: Summation o ...

  8. Summation of Four Primes - PC110705

    欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/uva10168.html 原创:Summ ...

  9. UVA 10168 Summation of Four Primes(数论)

    Summation of Four Primes Input: standard input Output: standard output Time Limit: 4 seconds Euler p ...

随机推荐

  1. JavaScript之原型深入详解

    理解原型 原型是一个对象,其他对象可以通过它实现属性继承.任何一个对象都可以成为继承,所有对象在默认的情况下都有一个原型,因为原型本身也是对象,所以每个原型自身又有一个原型.任何一个对象都有一个pro ...

  2. java排序算法-插入排序

    public class InsertSortUtils { public static void main(String[] args) { insertSortTest(); shellSortT ...

  3. 集群中几种session同步解决方案的比较

    1. 客户端cookie加密 .比较好的方法是自己采用cookie机制来实现一个session,在应用中使用此session实现. 问题:session中数据不能太多,最好只有个用户id. Sessi ...

  4. [转] What is Ec/Io (and Eb/No)?

    PS:http://www.telecomhall.com/what-is-ecio-and-ebno.aspx If someone asks you "Which Signal Leve ...

  5. 【网络流#8】POJ 3469 Dual Core CPU 最小割【ISAP模板】 - 《挑战程序设计竞赛》例题

    [题意]有n个程序,分别在两个内核中运行,程序i在内核A上运行代价为ai,在内核B上运行的代价为bi,现在有程序间数据交换,如果两个程序在同一核上运行,则不产生额外代价,在不同核上运行则产生Cij的额 ...

  6. 帧动画 AnimationDrawable

    Drawable Animation(Frame Animation):帧动画,就像GIF图片,通过一系列Drawable依次显示来模拟动画的效果. 首先,在res/drawable中定义动画 < ...

  7. oracle中循环插入语句

    DECLARE i number:=30000;BEGIN for i in 1..100 loop insert into Maternal_Info(id,sjh,bbsr,cf) values( ...

  8. libthrift0.9.0解析(二)之TSimpleServer

    TSimpleServer简单实现Tserver,代码如下. /** * Simple singlethreaded server for testing. * */ public class TSi ...

  9. C# 截取字符串,区分中英文情况

    public static string SubstringByCN(string strInput, int begin, int length) { if (!Regex.IsMatch(strI ...

  10. 高放的c++学习笔记之类

    类的基本思想是数据抽象和封装1.this 成员函数通过一个名为this的额外隐式参数来访问调用它的对象,当我们调用一个函数的时候,用请求该函数的对象的初始化this. 如果某个类的名字为sale,某个 ...