Created
February 16, 2013 22:03
-
-
Save nsmaciej/4968928 to your computer and use it in GitHub Desktop.
This file contains 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
isPrime :: Int -> Bool | |
isPrime u | |
| u < 2 = False | |
| u == 2 = True | |
| otherwise = not $ maximum [ mod u x == 0 | x <- [2..s]] where s = u - 1 | |
main = do y <- readLn :: IO Int | |
mapM_ print $ filter (\x -> mod y x == 0 && isPrime x) [1..y] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment