Sieve of Eratosthenes[ZT]
2005-02-27 15:47
288 查看
Eratosthenes also conceived the "Sieve of Eratosthenes ", a method of identifying prime numbers.
A prime number is a natural number greater than 1 that can be divided without remainder only by itself and by 1. Natural numbers n that can be divided by a number less than n and greater than 1 are composite numbers. The Sieve of Eratosthenes identifies all prime numbers up to a given number n as follows:
Write down the numbers 1, 2, 3, ..., n. We will eliminate composites by marking them. Initially all numbers are unmarked.
Mark the number 1 as special (it is neither prime nor composite).
Set k=1. Until k exceeds or equals the square root of n do this:
Find the first number in the list greater than k that has not been identified as composite. (The very first number so found is 2.) Call it m. Mark the numbers
m is a prime number. Put it on your list.
Set k=m and repeat.
http://www.math.utah.edu/~alfeld/Eratosthenes.html
A prime number is a natural number greater than 1 that can be divided without remainder only by itself and by 1. Natural numbers n that can be divided by a number less than n and greater than 1 are composite numbers. The Sieve of Eratosthenes identifies all prime numbers up to a given number n as follows:
Write down the numbers 1, 2, 3, ..., n. We will eliminate composites by marking them. Initially all numbers are unmarked.
Mark the number 1 as special (it is neither prime nor composite).
Set k=1. Until k exceeds or equals the square root of n do this:
Find the first number in the list greater than k that has not been identified as composite. (The very first number so found is 2.) Call it m. Mark the numbers
2m, 3m, 4m, ...as composite. (Thus in the first run we mark all even numbers greater than 2. In the second run we mark all multiples of 3 greater than 3.)
m is a prime number. Put it on your list.
Set k=m and repeat.
http://www.math.utah.edu/~alfeld/Eratosthenes.html
相关文章推荐
- Sieve of Eratosthenes[ZT]
- Sieve of Eratosthenes[ZT]
- 找质数算法(Sieve of Eratosthenes筛法)
- 找质数算法(Sieve of Eratosthenes筛法)
- Sieve of Eratosthenes(埃拉托斯特尼素数筛选法)--java实现
- Sieve of Eratosthenes(埃拉托斯尼斯筛法)
- 埃拉托斯特尼筛法(Sieve of Eratosthenes)简单c实现
- Sieve of Eratosthenes求质数
- 素数筛法/埃拉托斯特尼筛法(sieve of Eratosthenes)——理解及具体问题
- 找质数算法(Sieve of Eratosthenes筛法)
- codility: Sieve of Eratosthenes (CountNonDivisible, CountSemiprimes)
- 生成质数的好方法:sieve of eratosthenes
- sieve of Eratosthenes——一种寻找素数的方法
- sieve of Eratosthenes 找质素
- 找质数算法(Sieve of Eratosthenes筛法)
- LeetCode - 204. Count Primes - 埃拉托斯特尼筛法 95.12% - (C++) - Sieve of Eratosthenes
- The Sieve of Eratosthenes
- Sieve Of Eratosthenes求素数(埃拉托斯特尼筛法)
- 素数筛法【Sieve Of Eratosthenes + Sieve Of Euler】
- 两种 eratosthenes 筛法的时间比较,第二种快很多会比较好用