The sieve of eratosthenes
polyglot page
On this page I am collecting versions of the Sieve of Eratosthenes algorithm in as many different languages as possible, in the spirit of the 99 bottles of beer and hello world page. The sieve is of course an algorithm for finding prime numbers.
Please feel free to send in your own. A few notes though: take a look at the output of one or two, as I would like the output as close as possible to this. There is no sense in adding a newline after every number, especially if there are 2000 of them. The program should find primes from 2 to any arbitrary number that is user specified. Although I am not intentionally trying to obscure this code, I don't really want punks stealing these for their homework either, and the rationale is if you can't explain the code to your teacher, you will likely fail, so a little obfuscation is all right. I am not looking for code that simply finds prime numbers. I am well aware there are quicker and more efficient ways to find primes. That is not the point, the point is to write the same algorithm in as many languages as possible, so Eratosthenes only please.
- Ada: [version 1]
- Assembly: [(x86) version 1] [(x86) version 2]
- Bash: [version 1]
- C: [version 1]
- Clean: [version 1]
- Cobol: [version 1]
- C++: [version 1]
- C#: [version 1]
- D: [version 1]
- Dylan: [version 1]
- Eiffel: [version 1]
- Erlang: [version 1]
- Forth: [version 1]
- Fortran: [version 1]
- Groovy: [version 1]
- Haskell: [version 1] [version 2]
- Io: [version 1]
- J: [version 1]
- Java: [version 1]
- JavaScript: [version 1]
- Lisp: [version 1]
- Lua: [version 1]
- Mercury: [version 1]
- ML: [version 1]
- Objective C: [version 1]
- OCaml: [version 1]
- Pascal: [version 1]
- Perl: [version 1]
- Perl 6: [version 1]
- PHP: [version 1]
- Prolog: [version 1]
- Python: [version 1]
- R: [version 1]
- Rexx: [version 1]
- Ruby: [version 1]
- Scheme: [version 1]
- Smalltalk: [version 1]
- SQL: [version 1]
- TCL: [version 1]
- XSL: [version 1]
Thanks to everyone that has sent a version in, and special thanks to Rob Hoelz, who has taken the time to write and send in the large majority of sieve versions on this page.
Please send contributions to bulliver at badcomputer dot org, or click on my name at the bottom of the page.
stats
It is
Thursday July 24, 2008 9:32 am
This page served 5282 times
This page last modified: April 29, 2008 2:11 pm
Your IP address is: 38.103.63.16
You are browsing using: CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
You are browsing from: United States.
badcomputer.org's uptime: 09:32:11 up 12 days, 19:59, 3 users, load average: 1.03, 1.03, 1.00
local
home | unix stuff | dir2ogg | sneetchalizer | wmainfo | q&d guide to permissions | q&d guide to tar and gzip | code | MS rant | browser shootout | linux & iAudio X5 | photos | music | programming poetry | sieve of Eratosthenes | plea | rain | suffer | archive | about | recipes | compaqr3000 | sitemap
search
credits
This page, and all pages on this site were created and are maintained by Darren Kirby using valid XHTML 1.0 and CSS, and are ©copyright 2002 - 2008. The Penguin image was created by Tukka, and is used by permission. Inspiration for the look of this site was provided by Eric A. Meyer's CSS gallery. This website runs on Gentoo Linux. It is served by Apache. PHP and MySQL hold together the backend.