Skip to content

Instantly share code, notes, and snippets.

@mkakh
Created November 1, 2018 15:54
Show Gist options
  • Save mkakh/9790a9d2821d329f287623ec157cb7f7 to your computer and use it in GitHub Desktop.
Save mkakh/9790a9d2821d329f287623ec157cb7f7 to your computer and use it in GitHub Desktop.
import System.Environment (getArgs)
primes = filterPrime [2..]
where filterPrime (p:xs) = p : filterPrime [x | x <- xs, x `mod` p /= 0]
main :: IO ()
main = do
args <- getArgs
if length args < 1
then
putStrLn "Usage: ./prime N"
else do
print $ take (read $ args !! 0) primes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment