Skip to content

Instantly share code, notes, and snippets.

@nsmaciej
Created February 16, 2013 22:03
Show Gist options
  • Save nsmaciej/4968928 to your computer and use it in GitHub Desktop.
Save nsmaciej/4968928 to your computer and use it in GitHub Desktop.
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