https://projecteuler.net/problem=7
2016-02-24 20:33
627 查看
10001st prime
Problem 7
Publishedon Friday, 28th December 2001, 06:00 pm; Solved by 257306; Difficulty rating: 5%
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10 001st prime number?
本来想用最笨的方法,从小到大一个一个算,后来看到素筛法,就随便写了些,还是感觉,如果数量再大,这个方法也不好用
upper = 200010 listprime = [True] * (upper+1) for i in range(2,upper+1): if listprime[i] == True: temp = i * 2 while temp < upper: listprime[temp] = False temp += i count = 0 i = 2 while count < 10001 and i < upper: if listprime[i] == True: count += 1 i += 1 print(i-1) print(count)
相关文章推荐
- 网络原理学习1
- 网络交换卡
- 上机题目(初级)- Java网络操作-打印网页(Java)
- 原生Ajax的XMLHttpRequest对象使用指南
- 使用线程进行网络图片下载(一)
- 网络的最大流最小割定理
- viewpageindicator +fragment 在网络访问中与volley框架 null问题
- 网络的理解2
- ios: 使用http进行通信(Transport Security has Blocked a cleartext HTTP)
- 网络的理解
- 网络的理解
- [Computer Security : Art and Science] Chapter_1 1.1 基础部分
- PXE网络引导自动化安装系统详解
- HTTPS原理
- Android编程获取网络连接状态(3G/Wifi)及调用网络配置界面
- volley Request添加Header的HTTP请求
- linux网络编程相关函数(一)
- Linux网络配置问题心得
- Http中Get与Post区别详解
- 网络框架 Retrofit