Calling all programmers - Sieve of Eratosthenes
Posted 04-08-2006 at 06:04 PM by bulliver
In the spirit of the <a href="http://www.99-bottles-of-beer.net/">99 bottles of beer</a> and <a href="http://www2.latech.edu/~acm/HelloWorld.shtml">hello world</a> page, I have started a page on my site to collect the Sieve of Eratosthenes algorithm written in as many languages as possible. So far I only have five, and I wrote them all myself but I am looking for contributions. I am going to keep plugging away at this on my own as an exercise, but I would really like to see some involvement from the community. For more information on writing a program, or the algorithm itself, please <a href="http://badcomputer.org/unix/code/eratosthenes.bot">check it out</a>.
Also, I while back I put in a request for screenshots of my website in the General Forum, stating that I would use them for a write-up on how certain browsers render standards compliant code. Well, it only took me 3 months, but finally I have done so. Check out the <a href="http://badcomputer.org/unix/badbrowser.bot">(not so) surprising results</a>.
Also, I while back I put in a request for screenshots of my website in the General Forum, stating that I would use them for a write-up on how certain browsers render standards compliant code. Well, it only took me 3 months, but finally I have done so. Check out the <a href="http://badcomputer.org/unix/badbrowser.bot">(not so) surprising results</a>.
Total Comments 2
Comments
-
Try this link
http://primes.utm.edu/links/programs/sieves/Eratosthenes/
for C and JAVA
Here's a FORTRAN version
program prime2
implicit none
integer, parameter :: maxnum=1000
integer, dimension(maxnum) :: prod, pnum
integer :: i, j, max_i, max_j, nprime=0
do i = 1, maxnum
prod(i) = 0
enddo
max_i = floor(sqrt(real(maxnum)))
do i = 2, max_i
if (prod(i) == 0) then
max_j = maxnum/i
do j = 2, max_j
prod(i*j) = 1
enddo
end if
end do
do i = 2, maxnum
if (prod(i) == 0) then
nprime = nprime + 1
pnum(nprime) = i
end if
enddo
print *, 'Number of primes found = ',nprime
print "(10i5)", (pnum(i), i=1,nprime)
end program prime2
do a little googleing, you will find lots more
BobJPosted 12-31-1969 at 07:00 PM by bulliver -
Hi Bobj,
I don't know much about Fortran, but I couldn't get this one to compile. I am getting many messages like: "Non-numeric character at (^) in label field [info -f g77 M LEX]". Did you write it? I don't really want to just copy the code from the internet, I want to either write it or have it submitted, so I can give proper credit.Posted 12-31-1969 at 07:00 PM by bulliver