LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > bulliver
User Name
Password

Notices


Rate this Entry

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>.
Posted in Uncategorized
Views 2478 Comments 2
« Prev     Main     Next »
Total Comments 2

Comments

  1. Old Comment
    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

    BobJ
    Posted 12-31-1969 at 07:00 PM by bulliver bulliver is offline
  2. Old Comment
    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 bulliver is offline
 

  



All times are GMT -5. The time now is 09:30 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration