Skip to content

Instantly share code, notes, and snippets.

@bradyt
Created August 21, 2016 12:17
Show Gist options
  • Save bradyt/7db45a92f31b088111be1bcc610545f5 to your computer and use it in GitHub Desktop.
Save bradyt/7db45a92f31b088111be1bcc610545f5 to your computer and use it in GitHub Desktop.
sieve :: ([Int], [Int]) -> ([Int], [Int])
sieve p=if (null (snd p))
then p
else sieve ( fst p ++ [ head $ snd p ]
, filter (\n -> (/=0) $ mod n $ head $ snd p ) $ tail $ snd p )
sieven :: Int -> [Int]
sieven n = fst $ sieve ([2], [3,5..n])
list20k = sieven 20000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment