Created
April 7, 2010 16:55
-
-
Save stephenpaulger/359124 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(sieve). | |
-export([sieve/1]). | |
sieve(N) -> | |
[1 | sieve(lists:seq(2, N), N)]. | |
sieve([Head|L], N) when Head * 2 < N -> | |
[Head | sieve(L -- lists:seq(Head * 2, N, Head), N)]; | |
sieve([Head|L], _) -> | |
[Head | L]. |
Author
stephenpaulger
commented
Apr 10, 2010
- view Started with some experiments in the Erlang shell.
- view Created a recursive implementation based on my experiments
- view Reformatted to make it more readable.
- view Change to use a more common way of adding items to the head of a list.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment