Algorithms
2015-06-11 03:33
411 查看
Count prime numbers not exceeding n(n>0)
The Sieve of Eratosthenes uses an extra O(n) memory and its runtime complexity is O(n log log n).
d
d
d
d
d
d
d
d
d
Pseudocode: Input: an integer n > 1 Let A be an array of Boolean values, indexed by integers 2 to n, initially all set to true. for i = 2, 3, 4, ..., not exceeding √n: if A[i] is true: for j = i2, i2+i, i2+2i, i2+3i, ..., not exceeding n : A[j] := false Output: all i such that A[i] is true.
The Sieve of Eratosthenes uses an extra O(n) memory and its runtime complexity is O(n log log n).
d
d
d
d
d
d
d
d
d
相关文章推荐
- VIEWGOOD(远古)军队演习实训远程高清直播的应用
- Google的镜像
- Django知识点总结(一)
- Algorithms—22.Generate Parentheses
- 为什么科技巨头们纷纷更换 Logo?
- Go语言统计中文词语的个数,分词.
- googel 图片搜索原理
- Algorithms—17.Letter Combinations of a Phone Number
- Go语言Slice去重
- 关于socket长连接的心跳包GOOD
- hoj2430 Counting the algorithms
- Django:快速搭建简单的Blog
- Django:快速搭建简单的Blog 分类: 软件插件学习 2015-06-10 18:07 35人阅读 评论(0) 收藏
- Google推荐的图片加载库Glide介绍
- 一个关于类别(category)使用的例子
- runtime--实现篇02(Category增加属性)
- 软件开发流程之Scrum/Sprint开发方法
- Golang Deco Enco
- 用Go语言做产品半年的一些感觉
- 你能识别这些科技公司的真假logo吗?