Created
November 1, 2018 15:54
-
-
Save mkakh/9790a9d2821d329f287623ec157cb7f7 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
| 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