Skip to content

Instantly share code, notes, and snippets.

@leogao2
Created September 11, 2019 20:09
Show Gist options
  • Save leogao2/c7dc0230d44ea87e5730f11a1037fda7 to your computer and use it in GitHub Desktop.
Save leogao2/c7dc0230d44ea87e5730f11a1037fda7 to your computer and use it in GitHub Desktop.
Haskell prime numbers (inefficient)
p :: (Integral a) => a -> Bool
p 2 = True
p x = not (any id (map (==0) (map (mod x) (filter p [2..x-1]))))
main = do print (take 10 (filter p [2..]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment