是我算法不对,还是笔记本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. Linux 下最为人熟知的解压缩工具

    很多时候,通过互联网发送或接收大文件和图片是一件令人头疼的事.压缩及解压缩工具正好可以应对这个问题.下面让我们快速浏览一些可以使得我们的工作更加轻松的开源工具. Tar Tar 由 ‘Tape arc ...

  2. 使用XSLT实现Word下载

    Xslt是Extensible Stylesheet Language Transformations的缩写,用来将XML 文档转换到其它文档类型.XSLT的使用包括两个输入文件: – 包含实际数据的 ...

  3. Java中直接输出一个类的对象

    例如 package com.atguigu.java.fanshe; public class Person { String name; private int age; public Strin ...

  4. ubuntu下mysql的常用命令

    首先安装mysql:sudo?apt-get?install?mysql-server?mysql-client? 1.终端启动MySQL:/etc/init.d/mysql start:(stop ...

  5. cocoa Touch-UIKit

    1. 简介: UIKitk框架提供一系列的Class(类)来建立和管理iPhone OS应用程序的用户界面( UI )接口.应用程序对象.事件控制.绘图模型.窗口.视图和用于控制触摸屏等的接口. (P ...

  6. iOS 设备和外部配件的通讯

    首先,如果我们的应用程序想跟外设传输数据,先要透过iphone的操作系统,也就是iphoneOS,而最开始的认证过程也是在外设和iphoneOS之间发生的,苹果为这个过程提供了一颗认证芯片(这颗芯片的 ...

  7. SKPhysicsJointLimit类

    继承自 NSObject 符合 NSCoding(SKPhysicsJoint)NSObject(NSObject) 框架  /System/Library/Frameworks/SpriteKit. ...

  8. COM编程入门第二部分——深入COM服务器

    本文为刚刚接触COM的程序员提供编程指南,解释COM服务器内幕以及如何用C++编写自己的接口.继上一篇COM编程入门之后,本文将讨论有关 COM服务器的内容,解释编写自己的COM接口和COM服务器所需 ...

  9. Asp.Net MVC 页面代码压缩筛选器-自定义删除无效内容

    Asp.Net MVC 页面代码压缩筛选器 首先定义以下筛选器,用于代码压缩. /*页面压缩 筛选器*/ public class WhiteSpaceFilter : Stream { privat ...

  10. JS日期格式化函数性能优化篇

    最近开发的软件中需要用到日志功能,其中有一个重要功能是显示日期和时间.于是网上搜了一把,搜到大量的日期格式化函数,不过比较了下,感觉代码都不够优雅,而且性能都不给力.对线上一些代码进行了评测,以下是一 ...