Skip to content

Instantly share code, notes, and snippets.

@PhDP
Created November 13, 2012 17:28
Show Gist options
  • Save PhDP/4067155 to your computer and use it in GitHub Desktop.
Save PhDP/4067155 to your computer and use it in GitHub Desktop.
getPrimes = f [2, 3] 5
f ps n max = if n >= max then
ps
else if pr n then
f (ps ++ [n]) (n + 2) max
else
f ps (n + 2) max
where pr y = foldl (&&) True (map (\x -> mod y x > 0) ps)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment