Hi briguy8971!!
Here is what i found to help you. If it is not suffice, please let me
know and I will continue researching.
"The Sieve of Eratosthenes":
"Eratosthenes devised a 'sieve' to identify prime numbers. A sieve is
like a strainer that you drain spaghetti through when it is done
cooking. The water drains out, leaving your spaghetti behind. The
Sieve of Eratosthenes drains out composite numbers and leaves prime
numbers behind:
- Make a list of all the integers less than or equal to n (and greater than one).
- Strike out the multiples of all primes less than or equal to the
square root of n.
- Then the numbers that are left are the primes."
This page shows an algorith written in pseudo-code.
http://primes.utm.edu/glossary/page.php?sort=SieveOfEratosthenes
Here you will find some algorithms:
"Sieve of Eratosthenes"
Here you will find an explanation about how to write a Sieve of
Eratosthenes algorithm.
http://rvcc2.raritanval.edu/~tsiefrin/c-labs-sieve.htm
"QBasic - Sieve of Eratosthenes":
This algorithm finds all the primes up to some bound by implementing
the sieve of Eratosthenes.
http://www.math.umbc.edu/~campbell/NumbThy/Class/Programming/QBASIC/PRIMSIEV.BAS
"Sieve of Eratosthenes Benchmark":
At the 'Source Code' you will find links to algorithms written in
different programming languages.
http://www.bagley.org/~doug/shootout/bench/sieve/
Here is the one that I recommend to do a flowchart (note that the
QBasic one is another good choice):
"Sieve of Eratosthenes"
http://www.roguewave.com/support/docs/sourcepro/stdlibug/5-4.html
---------------------------------------------------------
Here is a "translation" of the algorithm that makes you easy the
construction of the flowchart (please test it!!):
- Input the number N (the size of the sieve)
N
- Create an array of ints, initially set all to 1.
a[x] = 1 for all x from 1 to N.
- Starting at i = 2, at positions that are multiples of i, set value to zero.
i = 2
(Main loop)
WHILE (i*i =< N)
DO
(Second loop)
IF a[i] = 1
THEN
j = i + i
(Third loop)
WHILE j =< N
DO
a[j] = 0
j = j + i
End of WHILE (End of 3rd loop)
End of IF (End of 2nd loop)
i = i + 1
End of WHILE (End of main loop)
- Now output all the values that are still set.
j = 2
WHILE j =< N
DO
IF a[j] = 1
THEN
PRINT j
End of IF
j = j + 1
End of WHILE
END of PROGRAM.
----------------------------------------------------------
Another "Sieve of Eratosthenes" algorithm:
http://www.comp.dit.ie/rlawlor/Prob_Solv/Imperative_Algs/Sieve%20of%20Eratosthenes.pdf
Finally a list of resources that will help you to do flowcharts:
"Designing programs with flow charts"
http://users.evtek.fi/~jaanah/IntroC/DBeech/3gl_flow.htm
"Programming Tools"
http://acweb.colum.edu/users/rcourington/Progclass/week2.html
More advanced references:
"Arrays and Bounded Iteration" from the School of Informatics,
University of Edinburgh:
See sections 16.3 and 16.4
http://www.inf.ed.ac.uk/teaching/classes/cs1/03-04/Ah/Notes/JavaArrays.pdf
"Loops" from the School of Computer Science at the University of Birmingham:
http://www.cs.bham.ac.uk/~udr/Intro/2001/handouts/handout07.pdf
"Introduction to Arrays" from University of Cincinnati:
http://homepages.uc.edu/~eshomtl/it171/Class7.ppt
Search strategy:
sieve of eratosthenes flowchart
"sieve of eratosthenes" algorithm
flowchart programming sample
flowchart programming sample array
I hope this helps. Please note that the algorithm "translation" have
minor chages from the original, the intention of this changes is to
adapt the algorithm for an easy flowchart, this changes can result in
an erroneous algorithm, so I strongly suggest you to test it and
improve it if it is necessary. It will be better if you can do the
flowchart from the original algorithm.
Feel free to request for any clarification needed.
Best regards.
livioflores-ga |