Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Blogs > bulliver
User Name


Rate this Entry

Calling all programmers - Sieve of Eratosthenes

Posted 04-08-2006 at 07:04 PM by bulliver

In the spirit of the <a href="">99 bottles of beer</a> and <a href="">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="">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="">(not so) surprising results</a>.
Posted in Uncategorized
Views 1835 Comments 2
« Prev     Main     Next »
Total Comments 2


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

    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
    end if
    end do

    do i = 2, maxnum
    if (prod(i) == 0) then
    nprime = nprime + 1
    pnum(nprime) = i
    end if
    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

    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 05:04 AM.

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