0
   

The Sieve?

 
 
NeoGuin
 
Reply Wed 5 Mar, 2003 07:55 am
As a computer programmer, I'm looking for things to add to an on-line portfolio.

One thing I remember reading about a technique for finding primes called "The Sieve".

I just need to remember:

1. What the real name is

2. How the technique works.
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 0 • Views: 997 • Replies: 2
No top replies

 
satt fs
 
  1  
Reply Wed 5 Mar, 2003 08:40 am
The sieve of Eratosthenes.
(Eratosthenes: 275 B.C.E. ~ 194 B.C.E.)


n: Target integer
i) let integer L be the square root of n /* square root is not essential L=n/2 or even L=n will do*/

ii) let {a(2),a(3), ..,a(n)} be an array with initial value 1 for every component
a(2)=1,
a(3)=1,
..
a(k)=1,
..
a(n)=1.

iii) for every k=2,..,L,

if a(k)=1,
for every j with k<j<=L, if k devides j then put a(j)=0;
else if a(k)=0, continue next step.
if k=L, stop the iteration
if k<L, k=k+1 (continue).

iv) the outcome array {a(2), a(3), .., a(n)} gives all the primes not greater than n, i.e.,

if a(i)=0 then i is a composite number,
if a(i)=1 then i is a prime.
0 Replies
 
NeoGuin
 
  1  
Reply Wed 5 Mar, 2003 11:36 am
satt:

Thanks.

For the uninitiated, this is a common way to test how fast a computer can run.
0 Replies
 
 

Related Topics

Clone of Micosoft Office - Question by Advocate
Do You Turn Off Your Computer at Night? - Discussion by Phoenix32890
The "Death" of the Computer Mouse - Discussion by Phoenix32890
Windows 10... - Discussion by Region Philbis
Surface Pro 3: What do you think? - Question by neologist
Windows 8 tips thread - Discussion by Wilso
GOOGLE CHROME - Question by Setanta
.Net and Firefox... - Discussion by gungasnake
Hacking a computer and remote access - Discussion by trying2learn
 
  1. Forums
  2. » The Sieve?
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.04 seconds on 05/03/2024 at 06:30:56