diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2021-07-24 01:36:43 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2021-07-24 01:36:43 +0100 |
commit | b03822dc08da74a4815f5e5e040c85819e019775 (patch) | |
tree | 93acccc063a1b160abcc1e5a9b6f626998ff733b /Math.hs | |
parent | 0f41ec16f14b0dbc26f633a01c3cbbcd0dbda75e (diff) | |
download | numberdisplay-b03822dc08da74a4815f5e5e040c85819e019775.tar.gz numberdisplay-b03822dc08da74a4815f5e5e040c85819e019775.tar.bz2 numberdisplay-b03822dc08da74a4815f5e5e040c85819e019775.zip |
Diffstat (limited to 'Math.hs')
-rw-r--r-- | Math.hs | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -1,9 +1,10 @@ module Math where - isPrime :: Int -> Bool - factors :: Int -> [Int] - intersect' :: [Int] -> [Int] -> [Int] - isPrime n = (length [ x | x <- [2..(ceiling $ sqrt $ fromIntegral 2)], - n `mod` x == 0]) == 0 - factors n = [x | x <- [1..(n `div` 2)], n `mod` x == 0] ++ [n] - intersect' a b = [x | x <- a, x `elem` b] +isPrime :: Int -> Bool +isPrime n = (length [ x | x <- [2..(ceiling $ sqrt $ fromIntegral 2)], + n `mod` x == 0]) == 0 +factors :: Int -> [Int] +factors n = [x | x <- [1..(n `div` 2)], n `mod` x == 0] ++ [n] + +intersect' :: [Int] -> [Int] -> [Int] +intersect' a b = [x | x <- a, x `elem` b] |