是我算法不对,还是笔记本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. 深入理解java的异常处理机制

     JAVA异常的概念    异常指不期而至的各种状况,如:文件找不到.网络连接失败.非法参数等.异常是一个事件,它发生在程序运行期间,干扰了正常的指令流程.Java通 过API中Throwable类的 ...

  2. 使用jquery生成二维码

    二维码已经渗透到生活中的方方面面,不管到哪,我们都可以用扫一扫解决大多数问题.二狗为了准备应对以后项目中会出现的二维码任务,就上网了解了如何使用jquery.qrcode生成二维码.方法简单粗暴,[] ...

  3. 关于Web Api的HelpPage文档注释问题

    之前使用Microsoft.AspNet.WebApi.HelpPage的时候,一直为返回对象的注释发愁,以为这是个BUG. 这个注释的解决办法其实要从其原理理解就明白了. 因为HelpPage是读取 ...

  4. Unity3D Asset stored 已下载的位置

    Unity3D Asset stored下载资源在本地的什么目录里呢?C:\Users\accountName\AppData\Roaming\Unity\Asset Store

  5. [转] Transitions: Going from Shots to the Insulin Pump

    Part three of our article series on the common phases of type 2 diabetes management By Lance Porter ...

  6. [转] When exactly does the virtual table pointer (in C++) gets set for an object?

    PS: http://stackoverflow.com/questions/7934540/when-exactly-does-the-virtual-table-pointer-in-c-gets ...

  7. SpannableString的一个奇怪的问题

    今天使用spannableString遇到一个奇怪的问题,就是在setspan的时候,原本可以写成 spannableString.setSpan(new RelativeSizeSpan(0.5f) ...

  8. (转)使用DataTime这个类来获取当前的时间

    我们可以通过使用DataTime这个类来获取当前的时间.通过调用类中的各种方法我们可以获取不同的时间:如:日期(--).时间(::).日期+时间(-- ::)等. //获取日期+时间 DateTime ...

  9. css文件和js文件后面带一个问号

    经常看一些网站页面源代码中的css文件和js文件后面带一个问号,后面跟着一连串数字或字符,这是干什么用的? 这个方法我也用过,而且很好用?,它的作用有两个:1.作为版本号,让自己方便记忆.查找:2.作 ...

  10. 合理使用Memcached进行缓存部署

    Memcached是danga.com(运营 LiveJournal的技术团队)开发的一套分布式内存对象缓存系统,用于在动态系统中减少数据库负载,提升性能.关于这个东西,相信很多人都用过,本 文意在通 ...